From a610648d7b0fc5ef58fd62ce7a747168adcc5ad6 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Wed, 17 Jul 2024 20:23:55 +0200 Subject: [PATCH] Try to fix redirect_uri being http when behind reverse proxy --- SS14.Admin/Startup.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/SS14.Admin/Startup.cs b/SS14.Admin/Startup.cs index 1b36179..673e1b1 100644 --- a/SS14.Admin/Startup.cs +++ b/SS14.Admin/Startup.cs @@ -70,6 +70,16 @@ public void ConfigureServices(IServiceCollection services) options.Scope.Add("profile"); options.GetClaimsFromUserInfoEndpoint = true; + options.Events.OnRedirectToIdentityProvider = context => + { + if (context.ProtocolMessage.RedirectUri.StartsWith("http://")) + { + context.ProtocolMessage.RedirectUri = string.Concat("https://", + context.ProtocolMessage.RedirectUri.AsSpan("http://".Length)); + } + return Task.CompletedTask; + }; + options.Events.OnTokenValidated = async ctx => { var handler = ctx.HttpContext.RequestServices.GetRequiredService();