From 46cfa0c8d082ff88e3d2edd4d3bb8a75506cc12b Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 27 Aug 2026 16:09:55 -0400 Subject: [PATCH] fix: Keep OIDC provider identifier in sync with configured domain (#13574) --- plugins/oidc/server/auth/oidcRouter.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/oidc/server/auth/oidcRouter.ts b/plugins/oidc/server/auth/oidcRouter.ts index a5e9e517c8..db936004a1 100644 --- a/plugins/oidc/server/auth/oidcRouter.ts +++ b/plugins/oidc/server/auth/oidcRouter.ts @@ -164,9 +164,25 @@ export function createOIDCRouter( // Derive a providerId from the OIDC location if there is no existing provider. const oidcURL = new URL(endpoints.authorizationURL); - const providerId = + let providerId = authenticationProvider?.providerId ?? oidcURL.hostname; + // The provider can move to a different domain, in which case the + // stored identifier must follow the configured location. + if (authenticationProvider && providerId !== oidcURL.hostname) { + try { + await authenticationProvider.update({ + providerId: oidcURL.hostname, + }); + providerId = oidcURL.hostname; + } catch (error) { + Logger.warn( + "Could not update OIDC authentication provider identifier", + { providerId, hostname: oidcURL.hostname, error } + ); + } + } + if (!domain) { throw OIDCMalformedUserInfoError(); }