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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user