You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When developing locally with authorization server it is common for devs to use localhost instead of 127.0.0.1 when testing with a public client using angular I ran into an issue where the redirect_uri was rejected. I turned on tracing with
But got no output explaining why the uri was rejected. Visual checking of the setting in the angular client and the client registration on the auth server side seemed to match redirect uri is set to http://localhost:4200. After tracing into the auth server I found the root cause in
if (requestedRedirectHost == null || requestedRedirectHost.equals("localhost")) {
Relevant code below
if (requestedRedirectHost == null || requestedRedirectHost.equals("localhost")) {
// As per https://tools.ietf.org/html/draft-ietf-oauth-v2-1-01#section-9.7.1
// While redirect URIs using localhost (i.e.,
// "http://localhost:{port}/{path}") function similarly to loopback IP
// redirects described in Section 10.3.3, the use of "localhost" is NOT RECOMMENDED.
return false;
}
The AuthServer should provide a more informative error message saying that the localhost is not allowed to be used as a redirect uri value. I think there are three possible enhancements:
so that it returns a boolean and a reason why the validation failed, this way the thrown exception can include an explanation of why this validation failed which will show up on the generated error page.
implement both 1 and 2
The text was updated successfully, but these errors were encountered:
asaikali
changed the title
adding tracing to explain why a redirect_uri rejected
adding tracing to explain why a redirect_uri is found to be invalid
Apr 8, 2022
jgrandja
changed the title
adding tracing to explain why a redirect_uri is found to be invalid
Improve error message when redirect_uri contains localhost
Apr 27, 2022
When developing locally with authorization server it is common for devs to use
localhost
instead of127.0.0.1
when testing with a public client using angular I ran into an issue where theredirect_uri
was rejected. I turned on tracing withBut got no output explaining why the uri was rejected. Visual checking of the setting in the angular client and the client registration on the auth server side seemed to match redirect uri is set to
http://localhost:4200
. After tracing into the auth server I found the root cause inspring-authorization-server/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2AuthorizationCodeRequestAuthenticationProvider.java
Line 523 in 718b86c
Relevant code below
The AuthServer should provide a more informative error message saying that the
localhost
is not allowed to be used as a redirect uri value. I think there are three possible enhancements:spring-authorization-server/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2AuthorizationCodeRequestAuthenticationProvider.java
Line 511 in 718b86c
spring-authorization-server/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2AuthorizationCodeRequestAuthenticationProvider.java
Line 511 in 718b86c
The text was updated successfully, but these errors were encountered: