spring-security icon indicating copy to clipboard operation
spring-security copied to clipboard

Add default redirect URI for OAuth2 client registration

Open yybmion opened this issue 8 months ago • 0 comments

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

yybmion avatar Apr 03 '25 06:04 yybmion