Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 029f5b5d8a | |||
| ff81325020 | |||
| 3e1b2eb48c | |||
| fc884c2350 | |||
| 2d833d3a90 | |||
| c152018be8 |
@@ -67,16 +67,14 @@ builder.Services.AddAuthentication(options =>
|
||||
|
||||
options.Events = new OpenIdConnectEvents
|
||||
{
|
||||
OnRedirectToIdentityProviderForSignOut = async callbackContext =>
|
||||
OnRedirectToIdentityProvider = context =>
|
||||
{
|
||||
var request = callbackContext.Request;
|
||||
string currentBaseUrl = $"{request.Scheme}://{request.Host}{request.PathBase}/";
|
||||
var fallbackUri = context.ProtocolMessage.RedirectUri;
|
||||
|
||||
callbackContext.ProtocolMessage.PostLogoutRedirectUri = currentBaseUrl;
|
||||
if (fallbackUri.StartsWith("http://", StringComparison.OrdinalIgnoreCase))
|
||||
context.ProtocolMessage.RedirectUri = fallbackUri.Replace("http://", "https://", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
var idToken = await callbackContext.HttpContext.GetTokenAsync("id_token");
|
||||
|
||||
if (!string.IsNullOrEmpty(idToken)) callbackContext.ProtocolMessage.IdTokenHint = idToken;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -95,6 +93,8 @@ var scheduler = await schedulerFactory.GetScheduler(ShopSchedulerName);
|
||||
if (!scheduler!.IsStarted)
|
||||
await scheduler.Start();
|
||||
|
||||
app.UseForwardedHeaders();
|
||||
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
||||
@@ -110,7 +110,6 @@ app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages:
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseAntiforgery();
|
||||
app.UseForwardedHeaders();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
@@ -119,11 +118,12 @@ app.MapStaticAssets();
|
||||
|
||||
app.MapGet("/auth/login", (string redirectUri = "/") =>
|
||||
Results.Challenge(new AuthenticationProperties { RedirectUri = redirectUri }, [OpenIdConnectDefaults.AuthenticationScheme]));
|
||||
|
||||
app.MapGet("/auth/logout", async (HttpContext context) =>
|
||||
{
|
||||
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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user