Skip to content

Add default redirect URI for OAuth2 client registration #16871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yybmion
Copy link

@yybmion yybmion commented Apr 3, 2025

Currently, OAuth2 client registration requires a redirect URI, and omitting it throws an exception during application startup. However, in most cases, users would use the standard pattern {baseUrl}/login/oauth2/code/{registrationId}.

Closes gh-16377

Implementation

  • Modified ClientRegistration.Builder.build() method to set a default redirectUri value when
    • redirectUri is null
    • authorizationGrantType is AUTHORIZATION_CODE
    • registrationId is available

Testing

  • Added a test to verify the default value is correctly applied when no redirect URI is provided
  • Removed the previous test that expected an exception in this scenario
  • Verified all existing tests continue to pass

When redirect URI is not provided for an OAuth2 client registration with
authorization code grant type, default it to {baseUrl}/login/oauth2/code/{registrationId}.

Closes spring-projectsgh-16377

Signed-off-by: yybmion <[email protected]>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 3, 2025
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.

Default value for ClientRegistration redirect-uri
2 participants