Skip to content

Conversation

@ryujungkyun
Copy link

Description

This PR addresses gh-18565, where the OAuth2AuthorizationConsentAuthenticationProvider incorrectly handles authorization consent for a RegisteredClient with no registered scopes.

When requireAuthorizationConsent(true) is set for a client with no scopes, the provider currently:

  1. Throws an ACCESS_DENIED error because it assumes an empty authority set implies user denial.
  2. Throws an IllegalArgumentException from OAuth2AuthorizationConsent.Builder because building with an empty authority set is not permitted.

Changes

  • Updated the logic to only throw ACCESS_DENIED if requestedScopes is not empty.
  • Conditionally call OAuth2AuthorizationConsent.Builder.build() only when authorities are present.
  • Added a cleanup step to remove stale consent records when the resulting authority set is empty.

Related Issue

Ref: gh-18565

How to Test

I have added a reproduction test case: authenticateWhenNoScopesAndConsentRequiredThenReturnAuthorizationCode() in OAuth2AuthorizationConsentAuthenticationProviderTests.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 25, 2026
@ryujungkyun ryujungkyun force-pushed the gh-18565-fix-consent-issue branch from 78bfea8 to 573fc92 Compare January 25, 2026 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants