-
-
Notifications
You must be signed in to change notification settings - Fork 527
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
Override BaseUri #1675
Comments
Hi,
openiddict-core/src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.cs Lines 92 to 120 in 3ec44a3
That said, you shouldn't use it: an incorrect inferred value is the sign ASP.NET Core itself didn't receive the correct information, which doesn't only affect OpenIddict but any other middleware that relies on |
Yes, I know that it would be better if all proxies would work correctly, but it is not the case. Therefore I would just like to enforce to use a specific host name when absolute URLs are generated. I went through this issue with the X-Forwarded-Host header at least 50 times now with my customers / users now. |
If the forwarded headers approach is not working, consider just adding a middleware that sets |
I think you misunderstand me. I would like to differentiate between:
So I would like to have an option for a "PublicUri" that just works like this: dev...SebastianStehle:openiddict-core:patch-1 |
Well, I've never seen a scenario where having a different host value for the two things would make sense, and it's certainly not a scenario ASP.NET Core itself supports (there's a single I still think setting |
I was thinking about this as well, but it has many other implications that I cannot predict. Perhaps I will just write a custom AttachEndpoints handler. |
You can, but it will only solve part of the problem: all the other ASP.NET Core components that rely on Here's another related thread that may interest you: #1610. |
I totally agree that they should just configure their reverse proxies correctly ... but this is the reality I live in. I will think about it. |
Do you know if something has changed with .NET 7? I have not changed anything, but it seems that a wrong host name was not a problem for .NET 6 (I am still running on 3.X). I am not entirely sure about that. |
Nope. To my knowledge, there are only two points that can affect OpenIddict:
Note: you probably already know it, but 3.x is no longer supported. |
Do you still need help, @SebastianStehle? 😃 |
No, it was indeed a problem with the host header. they have fucked up something in their configuration. |
Great to hear! 👍🏻 |
Hi Kevin, know this is old, but i just moved apps to container apps and they have their proxy. One of the things i needed to fix was the problem that the openid-configuration endpoint is adding http:// urls (since its hosted on http in the containers internally and ssl offload happens at the proxy). I did set the issuer to the public endpoint (https). Started looking for "baseuri" as to get the keys endpoint to show https (otherwise clients that call it gets no signing tokens found because it does not allow by default to load a http endpoint). Reading this thread i did however come to the conclussion that i should not set it myself, however i am 99% sure that the forwarded headers work and that the host should have been updated using that and discovery document should be okay, hoever it is not. Trying to validate if its indead a host header thing not propergating. |
Hi @pksorensen, Please open a new ticket (note: you need to sponsor the project to get support. More information here: https://github.com/sponsors/kevinchalet). Cheers. |
No worries - just wanted to leave the information to the next guy coming here. Turns out my problem was indeed the ForwardedHeadersOptions - where the host was considered a unknown host. I had only cleared proxies, but forgot to clear know networks. So anyone running into wrong urls in discovery document, validate that your setup is really correct. Enable debug/tracing to see the warnings from forwarded headers. Unknown proxy: [::1]:57639 |
Confirm you've already contributed to this project or that you sponsor it
Version
4.x
Question
Hi,
I always struggle with the several layers of proxies that some of my customers have. Very often, the actual public host name gets lost somewhere. This is an issue if you create absolute URLs.
Therefore I have a configuration value for the public URL. In
AttachEndpoints
you calculate the URIs based on the host URL if the configured URLs are not absolute.Would it be possible to introduce an option to override the base uri? I know that I could override AttachEndpoints method, but I would prefer a more lightweight option.
The text was updated successfully, but these errors were encountered: