fix: fall back to openid-configuration for auth server metadata discovery

Microsoft Entra ID and other OIDC providers expose metadata at
.well-known/openid-configuration rather than RFC 8414's
.well-known/oauth-authorization-server. Now tries both suffixes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
David Kaya
2026-03-27 20:06:02 +01:00
co-authored by Copilot
parent 0fd7a04a51
commit 4f7b479996
+5 -1
View File
@@ -160,7 +160,11 @@ async function discoverAuthorizationServer(serverUrl: string): Promise<string> {
}
async function fetchAuthServerMetadata(authServerUrl: string): Promise<AuthServerMetadata> {
const metadata = await fetchWellKnownMetadata(authServerUrl, 'oauth-authorization-server');
// RFC 8414 suffix first, then OpenID Connect Discovery suffix (used by Entra ID, Google, etc.)
const metadata =
(await fetchWellKnownMetadata(authServerUrl, 'oauth-authorization-server')) ??
(await fetchWellKnownMetadata(authServerUrl, 'openid-configuration'));
if (!metadata) {
throw new Error('Authorization Server Metadata fetch failed: no well-known endpoint found');
}