-
Notifications
You must be signed in to change notification settings - Fork 797
OAuth2AccessTokenInterceptor can handle Authentication Principal where principalName is null #1049
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
Comments
agileknight
added a commit
to agileknight/spring-cloud-openfeign
that referenced
this issue
Aug 19, 2024
The authorizedClientManager.authorize method requires a non-null principal name or it will usually throw an exception in practice like "principalName cannot be empty". Using the anonymous principal in this case like for a null principal handles the situation more gracefully. Fixes spring-cloud#1049
Hello @agileknight, thanks for reporting the issue. Makes sense. |
agileknight
added a commit
to agileknight/spring-cloud-openfeign
that referenced
this issue
Sep 5, 2024
The authorizedClientManager.authorize method requires a non-null principal name or it will usually throw an exception in practice like "principalName cannot be empty". Using the anonymous principal in this case like for a null principal handles the situation more gracefully. Fixes spring-cloud#1049
agileknight
added a commit
to agileknight/spring-cloud-openfeign
that referenced
this issue
Sep 5, 2024
The authorizedClientManager.authorize method requires a non-null principal name or it will usually throw an exception in practice like "principalName cannot be empty". Using the anonymous principal in this case like for a null principal handles the situation more gracefully. Fixes spring-cloud#1049
agileknight
added a commit
to agileknight/spring-cloud-openfeign
that referenced
this issue
Sep 5, 2024
The authorizedClientManager.authorize method requires a non-null principal name or it will usually throw an exception in practice like "principalName cannot be empty". Using the anonymous principal in this case like for a null principal handles the situation more gracefully. Fixes spring-cloud#1049
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
When
OAuth2AccessTokenInterceptor
encounters an Authentication Principal wheregetName
isnull
, it passes thenull
value on to theOAuth2AuthorizedClientManager
, which in practice usually results in a runtime exception likeprincipalName cannot be empty
.Describe the solution you'd like
The code already checks for a null principal an in that case passes ANONYMOUS_AUTHENTICATION. It appears to also make sense to pass ANONYMOUS_AUTHENTICATION for cases with a non-null principal but a null principal name.
Describe alternatives you've considered
Handling a null principal name downstream or upstream appears more complicated and it feels more natural to follow the current implementation of employing the ANONYMOUS_AUTHENTICATION placeholder for cases where the current authentication principal is not suitable.
Additional context
None
The text was updated successfully, but these errors were encountered: