From ee132ce9fe8de1e6ff1b080705c16e2f03840f08 Mon Sep 17 00:00:00 2001 From: Mark Ettema Date: Fri, 27 Dec 2019 04:26:50 +0700 Subject: [PATCH] Added support for PathBase to be used behind a reverse proxy --- src/Startup.cs | 11 ++++++++++- src/appsettings.Development.json | 3 +++ src/appsettings.json | 5 ++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Startup.cs b/src/Startup.cs index 146e59d..a562c62 100644 --- a/src/Startup.cs +++ b/src/Startup.cs @@ -41,7 +41,11 @@ namespace SteamOpenIdConnectProvider options.UserInteraction.LoginUrl = "/ExternalLogin"; }) .AddAspNetIdentity() - .AddInMemoryClients(IdentityServerConfig.GetClients(Configuration["OpenID:ClientID"], Configuration["OpenID:ClientSecret"], Configuration["OpenID:RedirectUri"], Configuration["OpenID:PostLogoutRedirectUri"])) + .AddInMemoryClients(IdentityServerConfig.GetClients( + Configuration["OpenID:ClientID"], + Configuration["OpenID:ClientSecret"], + Configuration["OpenID:RedirectUri"], + Configuration["OpenID:PostLogoutRedirectUri"])) .AddInMemoryPersistedGrants() .AddDeveloperSigningCredential(true) .AddInMemoryIdentityResources(IdentityServerConfig.GetIdentityResources()); @@ -63,6 +67,11 @@ namespace SteamOpenIdConnectProvider app.UseDeveloperExceptionPage(); } + if (!string.IsNullOrEmpty(Configuration["Hosting:PathBase"])) + { + app.UsePathBase(Configuration["Hosting:PathBase"]); + } + app.UseRouting(); app.UseIdentityServer(); app.UseEndpoints(endpoints => diff --git a/src/appsettings.Development.json b/src/appsettings.Development.json index e203e94..9988482 100644 --- a/src/appsettings.Development.json +++ b/src/appsettings.Development.json @@ -5,5 +5,8 @@ "System": "Information", "Microsoft": "Information" } + }, + "Hosting": { + "PathBase": "/test" } } diff --git a/src/appsettings.json b/src/appsettings.json index 5ea4b94..5582ca6 100644 --- a/src/appsettings.json +++ b/src/appsettings.json @@ -10,5 +10,8 @@ "RedirectUri": "http://localhost:8080/auth/realms/master/broker/steam/endpoint", "PostLogoutRedirectUri": "" }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "Hosting": { + "PathBase": "" + } } \ No newline at end of file