fix(admin-auth): use dedicated Keycloak secret key for sor-admin

This commit is contained in:
Shard
2026-04-30 23:32:43 +00:00
parent ee21346fb0
commit e150e9a485
3 changed files with 13 additions and 5 deletions
+7 -1
View File
@@ -37,6 +37,12 @@ var keycloakAuthority = builder.Configuration["Keycloak:Authority"]
var keycloakClientId = builder.Configuration["Keycloak:ClientId"]
?? throw new InvalidOperationException("Keycloak:ClientId is required. Set via Keycloak__ClientId env var.");
// Prefer an admin-specific secret key so SOR.Admin does not accidentally share
// a secret with other Keycloak clients (e.g. website). Fall back to the legacy
// Keycloak:ClientSecret key for backward compatibility.
var keycloakClientSecret = builder.Configuration["Keycloak:ClientSecret:Admin"]
?? builder.Configuration["Keycloak:ClientSecret"];
// ── Blazor Server ──────────────────────────────────────────────────────────
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
@@ -71,7 +77,7 @@ builder.Services
{
options.Authority = keycloakAuthority;
options.ClientId = keycloakClientId;
options.ClientSecret = builder.Configuration["Keycloak:ClientSecret"];
options.ClientSecret = keycloakClientSecret;
// If the public auth domain isn't reachable from inside the cluster (DNS/
// network policy), set Keycloak__MetadataAddress to the internal k8s service
// URL, e.g. http://keycloak.keycloak.svc.cluster.local:8080/realms/aeternalis
+2 -1
View File
@@ -28,7 +28,8 @@
"AllowedHosts": "*",
// Keycloak OIDC — override in production via k8s secret env vars:
// Keycloak__Authority, Keycloak__ClientId, Keycloak__ClientSecret
// Keycloak__Authority, Keycloak__ClientId, Keycloak__ClientSecret__Admin
// Legacy fallback still supported: Keycloak__ClientSecret
// A confidential client "sor-admin" must be created in the Keycloak realm with:
// - Valid redirect URI: https://<admin-host>/signin-oidc
// - Post-logout URI: https://<admin-host>/signout-callback-oidc
+4 -3
View File
@@ -85,12 +85,13 @@ spec:
name: sor-app-secrets
key: Admin__Password
# Keycloak OIDC confidential client secret (required for code→token exchange).
- name: Keycloak__ClientSecret
# Keycloak OIDC secret for the sor-admin client (required for code→token exchange).
# Use a dedicated key to avoid accidental secret sharing with other clients.
- name: Keycloak__ClientSecret__Admin
valueFrom:
secretKeyRef:
name: sor-app-secrets
key: Keycloak__ClientSecret
key: Keycloak__ClientSecret__Admin
# ASP.NET Core Data Protection — persists Blazor auth cookies across restarts.
# TODO: generate a strong random value and store in sor-app-secrets.