Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e1b2eb48c | |||
| fc884c2350 |
+8
-18
@@ -65,25 +65,15 @@ builder.Services.AddAuthentication(options =>
|
|||||||
RoleClaimType = "groups"
|
RoleClaimType = "groups"
|
||||||
};
|
};
|
||||||
|
|
||||||
options.Events = new OpenIdConnectEvents
|
builder.Services.AddOptions<OpenIdConnectOptions>(OpenIdConnectDefaults.AuthenticationScheme).Configure(options =>
|
||||||
{
|
{
|
||||||
OnRedirectToIdentityProviderForSignOut = async callbackContext =>
|
options.Events.OnRedirectToIdentityProvider = context =>
|
||||||
{
|
{
|
||||||
var request = callbackContext.Request;
|
context.ProtocolMessage.RedirectUri = context.ProtocolMessage.RedirectUri.Replace("http://", "https://");
|
||||||
string currentBaseUrl = $"{request.Scheme}://{request.Host}{request.PathBase}/";
|
|
||||||
|
return Task.CompletedTask;
|
||||||
callbackContext.ProtocolMessage.PostLogoutRedirectUri = currentBaseUrl;
|
};
|
||||||
|
});
|
||||||
var idToken = await callbackContext.HttpContext.GetTokenAsync("id_token");
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(idToken)) callbackContext.ProtocolMessage.IdTokenHint = idToken;
|
|
||||||
|
|
||||||
if (callbackContext.ProtocolMessage.RedirectUri.StartsWith("http://"))
|
|
||||||
{
|
|
||||||
callbackContext.ProtocolMessage.RedirectUri = callbackContext.ProtocolMessage.RedirectUri.Replace("http://", "https://");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.Configure<ForwardedHeadersOptions>(options =>
|
builder.Services.Configure<ForwardedHeadersOptions>(options =>
|
||||||
@@ -128,7 +118,7 @@ app.MapGet("/auth/logout", async (HttpContext context) =>
|
|||||||
{
|
{
|
||||||
await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
||||||
|
|
||||||
string currentBaseUrl = $"{context.Request.Scheme}://{context.Request.Host}{context.Request.PathBase}/";
|
string currentBaseUrl = $"https://{context.Request.Host}{context.Request.PathBase}/";
|
||||||
|
|
||||||
await context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties
|
await context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user