Skip to content
This repository was archived by the owner on Mar 6, 2025. It is now read-only.

public origin is not found in options in v4.x #4631

Closed
ignite-404 opened this issue Jul 7, 2020 · 14 comments
Closed

public origin is not found in options in v4.x #4631

ignite-404 opened this issue Jul 7, 2020 · 14 comments
Labels

Comments

@ignite-404
Copy link

var identityBuilder = collection.AddIdentityServer(option =>
            {
                //option.UserInteraction.ErrorUrl = "";
                var publicOrigin = config["public_origin"];
                if (publicOrigin?.Length > 0)
                {
                    option.PublicOrigin= publicOrigin;//complie error
                }
            });
@leastprivilege
Copy link
Contributor

We removed it. Use the forwarded headers instead.

@gegaryfa
Copy link

gegaryfa commented Jul 7, 2020

@hiwjcn To use forwarded headers:
In the Startup.ConfigureServices :

services.Configure<ForwardedHeadersOptions>(options =>
{
    options.ForwardedHeaders =
        ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto | ForwardedHeaders.XForwardedHost;
    options.KnownNetworks.Clear();
    options.KnownProxies.Clear();
});

In the Startup.Configure :

app.UseForwardedHeaders();

Then you can pass the headers X-Forwarded-Proto=<https or http> and X-Forwarded-host=<your_host> in the request.

@ignite-404
Copy link
Author

thanks, and pls update to the docs in the break change section :)

@themisir
Copy link

We removed it. Use the forwarded headers instead.

@leastprivilege,

Why did you removed it? Is there another way to modify origin? It did currently break our server. So I had to downgrade it to build project. I know I can use forwarded headers. But it doesn't works. The only way to fix that issue is using PublicOrigin :(

@unionthugface
Copy link

Just FYI this solves Issue 46 and Issue 324 as well for anyone who winds up on one of those pages first.

@g3v
Copy link

g3v commented Jul 31, 2020

@leastprivilege Does the fix with forwarded headers also corrects the endpoints in the Discovery Endpoint output document, so that they are relative to custom path?

@stale
Copy link

stale bot commented Aug 14, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Questions are community supported only and the authors/maintainers may or may not have time to reply. If you or your company would like commercial support, please see here for more information.

@stale stale bot added wontfix and removed wontfix labels Aug 14, 2020
@stale
Copy link

stale bot commented Aug 28, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Questions are community supported only and the authors/maintainers may or may not have time to reply. If you or your company would like commercial support, please see here for more information.

@stale stale bot added wontfix and removed wontfix labels Aug 28, 2020
@themisir
Copy link

Here's temporary fix 😅

Just add a middleware before identity server to modify host and protocol properties of HttpContext.Request. It worked for me =)

@CesarD
Copy link

CesarD commented Sep 9, 2020

I configured in Startup.ConfigureServices:

services.Configure<ForwardedHeadersOptions>(options =>
                                                        {
                                                            options.ForwardedHeaders = ForwardedHeaders.XForwardedFor |
                                                                                       ForwardedHeaders.XForwardedProto |
                                                                                       ForwardedHeaders.XForwardedHost;
                                                            options.KnownNetworks.Clear();
                                                            options.KnownProxies.Clear();
                                                        });

and in Startup.Configure:

app.UseForwardedHeaders()
               .UseHttpsRedirection()
               .UseCors()
               .UseStaticFiles()
               .UseRouting()
               .UseIdentityServer();

Still getting HTTP URLs in Discovery Document instead of HTTPS as expected.
I'd prefer to get back Public Origin setting. This is very annoying to solve when before we could solve it on our own without so much dependency from the network team.

What other alternative do I have right now if this Startup configurations don't work?

@M0ns1gn0r
Copy link
Contributor

@CesarD This is how I solved that:

app.Use((context, next) =>
{
	context.Request.Protocol = "https";
	context.Request.Host = new HostString("my-domain.com:12345");
	//  Only if you need it.
	context.Request.PathBase = new PathString("/api/auth");

	return next();
});

@CesarD
Copy link

CesarD commented Sep 10, 2020

Thanks a lot @M0ns1gn0r !! :)

@leastprivilege
Copy link
Contributor

#4857 (comment)

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

9 participants