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

OAuth2 invalid registrationId request to modify BAD_REQUEST status to respond

Open mhyeon-lee opened this issue 8 years ago • 5 comments

Summary

When an OAuth2 Authorization request encounters a ClientRegistration request that does not exist, it is responding with an InternalServerError. TestCase

Since the client has made an undefined request, it would be better to modify it in the BAD_REQUEST response.

Does this make sense?

mhyeon-lee avatar Jul 24 '18 13:07 mhyeon-lee

@mhyeon-lee As per spec, if the Authorization Request contains invalid parameters or missing parameters than the status should be 400.

However, if an incorrect clientRegistrationId is sent than a status of 500 is returned. The reason for this is because at this point the Authorization Request has not been triggered by the client and the client is unable to resolve the requested ClientRegistration because the clientRegistrationId does not exist in the ClientRegistrationRepository. IMO this use case is likely a configuration/setup error by the user so it signals to the user to correct the configuration.

jgrandja avatar Jul 26 '18 13:07 jgrandja

Related #4641

jgrandja avatar Jul 26 '18 13:07 jgrandja

I understood what it means. Thank you for your explanation.

And I think #4641 is a good feature.

mhyeon-lee avatar Jul 26 '18 14:07 mhyeon-lee

Thanks @mhyeon-lee. I'm going to close this issue since we're on the same page :)

jgrandja avatar Jul 26 '18 16:07 jgrandja

I feel this should be re-visited, I now have to implement a filter in the chain to customize this outcome to my specific requirements. This is a bad code smell:

.addFilterBefore(validator, OAuth2AuthorizationRequestRedirectFilter::class.java)

dennisaj avatar Jun 07 '23 14:06 dennisaj