Add Keycloak:MetadataAddress override for in-cluster OIDC discovery (SOR.Admin)

The pod cannot reach auth.aeternalisgames.com from inside the cluster (DNS/
network policy), so the OIDC middleware fails to fetch the discovery document
and throws "Cannot redirect to the authorization endpoint".

Add optional Keycloak__MetadataAddress env var. When set, the middleware
fetches the discovery doc from that URL (internal k8s service, HTTP allowed)
while still validating JWT issuer against the public Authority URL.

Set in sor-config:
  Keycloak__MetadataAddress=http://<keycloak-service>.<ns>.svc.cluster.local:<port>/realms/aeternalis

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-04-04 12:07:41 -04:00
co-authored by Claude Happy
parent bea1de3eb8
commit 6fc711323b
2 changed files with 16 additions and 1 deletions
+10
View File
@@ -61,6 +61,16 @@ builder.Services
options.Authority = keycloakAuthority;
options.ClientId = keycloakClientId;
options.ClientSecret = builder.Configuration["Keycloak:ClientSecret"];
// 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
// Authority is still used for issuer validation in token claims.
var metadataAddress = builder.Configuration["Keycloak:MetadataAddress"];
if (!string.IsNullOrEmpty(metadataAddress))
{
options.MetadataAddress = metadataAddress;
options.RequireHttpsMetadata = false; // internal URL may be plain HTTP
}
options.ResponseType = "code";
options.SaveTokens = true;
// Don't call the UserInfo endpoint — that extra pod→Keycloak HTTPS hop
+6 -1
View File
@@ -33,9 +33,14 @@
// - Valid redirect URI: https://<admin-host>/signin-oidc
// - Post-logout URI: https://<admin-host>/signout-callback-oidc
// - "sor-admin" realm role assigned to any user who should access this panel
// Keycloak:MetadataAddress — optional internal k8s service URL for OIDC discovery.
// Set Keycloak__MetadataAddress if the pod cannot reach the public auth domain.
// e.g. http://keycloak.keycloak.svc.cluster.local:8080/realms/aeternalis
// Authority is still used for JWT issuer validation regardless.
"Keycloak": {
"Authority": "https://auth.aeternalisgames.com/realms/aeternalis",
"ClientId": "sor-admin",
"ClientSecret": ""
"ClientSecret": "",
"MetadataAddress": ""
}
}