6 Commits

Author SHA1 Message Date
khwezi 029f5b5d8a Merge pull request 'Refactored forced https redirection' (#15) from notifications into master
Reviewed-on: #15
2026-05-17 11:35:49 +02:00
Khwezi Mngoma ff81325020 Refactored forced https redirection
continuous-integration/drone/pr Build is passing
2026-05-17 11:34:40 +02:00
khwezi 3e1b2eb48c Merge pull request 'Forcing https' (#14) from notifications into master
Reviewed-on: #14
2026-05-17 11:06:46 +02:00
Khwezi Mngoma fc884c2350 Forcing https
continuous-integration/drone/pr Build is passing
2026-05-17 11:06:05 +02:00
khwezi 2d833d3a90 Merge pull request 'Forced proto callback' (#13) from notifications into master
Reviewed-on: #13
2026-05-17 09:01:04 +02:00
Khwezi Mngoma c152018be8 Forced proto callback
continuous-integration/drone/pr Build is passing
2026-05-17 09:00:41 +02:00
+9 -9
View File
@@ -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
{