I was following this Demo example and was wondering why the Auth server config reads
redirect-uris:
- "http://127.0.0.1:1234/login/oauth2/code/my-webapp-client-oidc"
- "http://127.0.0.1:1234/authorized"
post-logout-redirect-uris:
- "http://127.0.0.1:1234/logged-out"
instead of
redirect-uris:
- "http://localhost:1234/login/oauth2/code/my-webapp-client-oidc"
- "http://localhost:1234/authorized"
post-logout-redirect-uris:
- "http://localhost:1234/logged-out"
I would assume that it makes no difference but it does. When changing the URIs to localhost, the auth server gives me an exception when trying to login:
org.springframework.security.access.AccessDeniedException: Access Denied
at org.springframework.security.web.access.intercept.AuthorizationFilter.doFilter(AuthorizationFilter.java:98) ~[spring-security-web-6.2.1.jar:6.2.1]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.2.1.jar:6.2.1]
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:126) ~[spring-security-web-6.2.1.jar:6.2.1]
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:120) ~[spring-security-web-6.2.1.jar:6.2.1]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.2.1.jar:6.2.1]
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:100) ~[spring-security-web-6.2.1.jar:6.2.1]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.2.1.jar:6.2.1]
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:179) ~[spring-security-web-6.2.1.jar:6.2.1]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:374) ~[spring-security-web-6.2.1.jar:6.2.1]
at...
Could you please explain that to me? Thank you.
it shouldn't matter whether u use
localhostor127.0.0.1or if you buy a domain name and attach it to your computer and use that. What DOES matter that you are consistent, and whichever URL you used to register is what you use to provide as callback (redirect).The reason is in the spec and according to OAauth2 seicifcation the authorization server will check the redirect uri match using a simple string comparison - see here. Therefore even one letter difference matters even if these urls dns resolution would end up being the same server.