8 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
khwezi aa7b3f3d68 Merge pull request 'Added support for header forwarding' (#12) from notifications into master
Reviewed-on: #12
2026-05-17 08:48:01 +02:00
Khwezi Mngoma c7f4aad99d Added support for header forwarding
continuous-integration/drone/pr Build is passing
2026-05-17 08:47:20 +02:00
2 changed files with 17 additions and 9 deletions
+15 -9
View File
@@ -1,6 +1,5 @@
using LiteCharms.Features.Extensions;
using LiteCharms.Features.Mediator;
using Microsoft.AspNetCore.Authentication;
using ShopAdmin.Components;
using static LiteCharms.Features.Email.Extensions.Constants;
@@ -68,20 +67,24 @@ 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;
}
};
});
builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
options.KnownProxies.Clear();
});
var app = builder.Build();
var schedulerFactory = app.Services.GetRequiredService<ISchedulerFactory>();
@@ -90,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);
@@ -113,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
{
+2
View File
@@ -57,6 +57,8 @@
<!-- Shared Global Usings -->
<ItemGroup>
<Using Include="Microsoft.AspNetCore.HttpOverrides" />
<Using Include="Microsoft.AspNetCore.Authentication" />
<Using Include="Blazored.Toast" />
<Using Include="Quartz" />
<Using Include="Mediator" />