-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Server request URL with spring-webflux 6.0.5 is in resolved IP6 format #30033
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
I think this is linked to #28601. Transferring this issue to Spring Framework. |
@bclozel - thanks for handling this. |
We suspect that spring-projects/spring-boot#34395 is another symptom of the same underlying problem. |
Indeed, both this issue and spring-projects/spring-boot#34395 are linked to the change in #28601. I tried the sample from spring-projects/spring-boot#34395, and the case there is an "X-Forwarded-Host" that contains both host and port (e.g. "localhost:3000"). When we parse the "Host" header ourselves, we handle this case. However, when relying on Reactor's The case reported here is a little different. It looks like |
See #30047 for a possible fix involving Netty's ˋNetUtil`. |
#30047 looks more of an optimization that avoids an extra URI creation. I'm not sure it solves the issues here, but worth to consider at the same time. |
As expected, Netty's @Intosoft if you can provide an isolated sample to debug or verify changes with, that would be very helpful. Probably no need to see the authorization failures, but just enough to get such a server URL that differs between 6.0.4 and 6.0.5. |
I think this is not a valid value https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host
|
But https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host
I would think that |
Here I think the
|
Also the port is present in both |
I definitely agree that it is odd to have the port in the I did think that |
We found a related issue when running spring-cloud-gateway with oauth spring-security integration. The redirect_uris sent to the auth server now contain the port (even when using 80) and when running with |
This is related to the first issue isn't it? Not the one with |
Here is an example that reproduces the problem for the first issue(the non
instead of
|
It seems to me the origin is the same. We see the same "localhost -> IP" change and as I said, I narrowed it down to this actual commit a2b7a90 and confirmed via debugging that we are entering into the new
Sadly not, it's a complex setup, including an Okta service. |
Thanks for the sample @msosa. I can't load the The other one is the "X-Forwarded-Host" with "host:port", and will be addressed in reactor/reactor-netty#2711. @abelsromero yes we know it's linked to that change, but it isn't as simple as reverting it, and we need to understand the scenarios in order to fix the issues for each. |
For the issue with |
I've scheduled this for 6.0.6, as we are expecting a change in Reactor Netty to provide a The |
Yes, the enhancement works on my project as well, thank you! Something to note though, when I set my UI port to 80 and go to |
This will be addressed with the changes that we are preparing for the other issue. |
- Prefer request hostName and hostPort in ReactorServerHttpRequest#resolveBaseUrl - The request hostName and hostPort are derived from the Host/X-Forwarded-*/Forwarded header associated with this request. - Do not add the port when it is the default one Closes spring-projectsgh-30033
We now have reactor/reactor-netty#2711 and reactor/reactor-netty#2714 in place, and also #30062 to take advantage of the new |
There is now a 6.0.6 snapshot available with the changes. If you have the option to test, please give it a try together with Reactor-Bom 2022.0.4 snapshot. I'll close this as superseded, but please feel free to add more comments. |
Thanks @msosa and @abelsromero for confirming the changes. |
After upgrade to spring boot 3.0.3, Swagger authorization stopped working on
http://localhost:8080
.The issue is caused by changed method:
From:
The root cause of issue is that instead of resolving host to
http://localhost
, it resolveshttp://[0:0:0:0:0:0:0:1]
.The main functionality of swagger works with this IP address, but authorization fails because it redirects to:
To fix that issue I can set
server.address
, but then it breaks accessing swagger by external IP.I found the issue after checking swagger, but rest of application works fine. Should openapi be fixed or
resolveBaseUrl
method?Even enforcing IP4 by
-Djava.net.preferIPv4Stack=true
does not solve issue.Downgrading to spring-web 6.0.4 solves the issue. Also using IP instead of DSN does not generate such issues.
The text was updated successfully, but these errors were encountered: