Compare commits

..

8 Commits

Author SHA1 Message Date
khwezi 6e580ecdf6 Merge pull request 'Added token hint to logout event' (#90) from payments into master
Reviewed-on: #90
2026-06-07 13:12:05 +02:00
Khwezi Mngoma 60095057b7 Added token hint to logout event
continuous-integration/drone/pr Build is passing
2026-06-07 13:11:33 +02:00
khwezi 4c194c1141 Merge pull request 'Added AddSecurityEndpoints login endpoint' (#89) from payments into master
Reviewed-on: #89
2026-06-07 12:00:50 +02:00
Khwezi Mngoma b41136e2c7 Added AddSecurityEndpoints login endpoint
continuous-integration/drone/pr Build is passing
2026-06-07 12:00:07 +02:00
khwezi 41eb4daeb4 Merge pull request 'Refactored AddSecurityEndpoints' (#88) from payments into master
Reviewed-on: #88
2026-06-07 11:09:02 +02:00
Khwezi Mngoma c423f04b42 Refactored AddSecurityEndpoints
continuous-integration/drone/pr Build is passing
2026-06-07 11:08:05 +02:00
khwezi 7fe5f7aef3 Merge pull request 'Refactored client auth method' (#87) from payments into master
Reviewed-on: #87
2026-06-07 10:33:33 +02:00
Khwezi Mngoma a567fc7cd7 Refactored client auth method
continuous-integration/drone/pr Build is passing
2026-06-07 10:30:56 +02:00
+22 -11
View File
@@ -10,7 +10,7 @@ public static class Api
public const string Books = nameof(Books); public const string Books = nameof(Books);
public const string Payments = nameof(Payments); public const string Payments = nameof(Payments);
public static IServiceCollection AddLiteCharmsUiSecurity(this IServiceCollection services, IConfiguration configuration) public static IServiceCollection AddLiteCharmsWebSecurity(this IServiceCollection services, IConfiguration configuration)
{ {
var configSection = configuration.GetSection(nameof(LiteCharmsSettings)); var configSection = configuration.GetSection(nameof(LiteCharmsSettings));
@@ -31,9 +31,8 @@ public static class Api
options.ClientId = authOptions.ClientId; options.ClientId = authOptions.ClientId;
options.ClientSecret = authOptions.ClientSecret; options.ClientSecret = authOptions.ClientSecret;
options.SignedOutCallbackPath = "/signout-callback-oidc";
options.ResponseType = "code"; options.ResponseType = "code";
options.SaveTokens = true; options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true; options.GetClaimsFromUserInfoEndpoint = true;
@@ -42,15 +41,27 @@ public static class Api
options.Scope.Add("profile"); options.Scope.Add("profile");
options.Scope.Add("email"); options.Scope.Add("email");
options.CorrelationCookie.SecurePolicy = CookieSecurePolicy.Always; options.Events = new OpenIdConnectEvents
options.CorrelationCookie.SameSite = SameSiteMode.None; {
options.CorrelationCookie.HttpOnly = true; OnRedirectToIdentityProviderForSignOut = context =>
{
var idToken = context.ProtocolMessage.IdTokenHint;
options.NonceCookie.SecurePolicy = CookieSecurePolicy.Always; if (string.IsNullOrEmpty(idToken))
options.NonceCookie.SameSite = SameSiteMode.None; {
options.NonceCookie.HttpOnly = true; var tokens = context.Properties.GetTokens();
var idTokenItem = tokens.FirstOrDefault(t => string.Equals(t.Name, "id_token", StringComparison.Ordinal));
if (idTokenItem != null) context.ProtocolMessage.IdTokenHint = idTokenItem.Value;
}
return Task.CompletedTask;
},
};
}); });
services.AddCascadingAuthenticationState();
return services; return services;
} }
@@ -87,7 +98,7 @@ public static class Api
{ {
await context.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties await context.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties
{ {
RedirectUri = redirectUri, RedirectUri = redirectUri,
}); });
}); });
@@ -99,7 +110,7 @@ public static class Api
await context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties await context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties
{ {
RedirectUri = currentBaseUrl RedirectUri = currentBaseUrl,
}); });
}); });