-
Notifications
You must be signed in to change notification settings - Fork 38.4k
oauth2 with ForwardedHeaderFilter bean does not respect Forwarded, nor X-Forwarded-Prefix headers #23647
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
The For the |
I have forked spring-security and in branch created my demonstration (sample project oauth2webclient). PS: In given branch, is also "solution" to my problem, which uses very crude way how to alter returned redirect_uri. It is based on some advice to use CustomAuthorizationRequestResolver. |
@luvarqpp as I pointed out previously in #23260 (comment) and here is that you need to A) make sure the You branch has the Adding the following declaration: @Bean
public FilterRegistrationBean<ForwardedHeaderFilter> forwardedHeaderFilter() {
ForwardedHeaderFilter filter = new ForwardedHeaderFilter();
FilterRegistrationBean<ForwardedHeaderFilter> registration = new FilterRegistrationBean<>(filter);
registration.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.ASYNC, DispatcherType.ERROR);
registration.setOrder(Ordered.HIGHEST_PRECEDENCE);
return registration;
} And you get:
|
Seems working. Thanks for answer. I have also searched once again documentation and also "google" and I have found nearly same problem as I had on stackoverflow with same solution :/ My apologize for spam. |
Affects: Spring Boot 2.1.8.RELEASE (Spring Framework 5.1.9)
I am using spring-security-oauth2-client for "log in" using github. My application is being deployed behind reverse proxy (nginx). Generated logi npage from oauth artefact does not have correct links (if I have more than one provider, login page lists them all and given links have missing prefix from http header X-Forwarded-Prefix).
Another problem is that redirect sent to github authorization url is wrong and it does not respect Forwarded header.
See also my similar report for simple login for spring-security here: spring-projects/spring-security#7081
My codebase now contains just https://github.com/spring-projects/spring-security/tree/master/samples/boot/oauth2login sample project "converted" to maven, with added single bean ForwardedHeaderFilter.
More info for second described problem: My nginx is sending proxied requests like this one:
Redirect url is than generated (copied log message here):
As you see redirect_uri parameter is set to internal address, where my spring application actually runs, instead of nginx proxy, which is available from Internet (qpp.qpp.sk).
The text was updated successfully, but these errors were encountered: