From de5717872d7244980710ad0ce4a1675364cf7660 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 10 Sep 2021 16:15:26 +0200 Subject: [PATCH] auth-backend: throw error if OIDC IdP does not have a userinfo endpoint Signed-off-by: Patrik Oldsberg --- .changeset/polite-dragons-allow.md | 5 +++++ plugins/auth-backend/src/providers/oidc/provider.ts | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/polite-dragons-allow.md diff --git a/.changeset/polite-dragons-allow.md b/.changeset/polite-dragons-allow.md new file mode 100644 index 0000000000..05eac53a1f --- /dev/null +++ b/.changeset/polite-dragons-allow.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-auth-backend': patch +--- + +Use a more informative error message if the configured OIDC identity provider does not provide a `userinfo_endpoint` in its metadata. diff --git a/plugins/auth-backend/src/providers/oidc/provider.ts b/plugins/auth-backend/src/providers/oidc/provider.ts index 306adc70f5..092ffa7099 100644 --- a/plugins/auth-backend/src/providers/oidc/provider.ts +++ b/plugins/auth-backend/src/providers/oidc/provider.ts @@ -157,6 +157,11 @@ export class OidcAuthProvider implements OAuthHandlers { userinfo: UserinfoResponse, done: PassportDoneCallback, ) => { + if (typeof done !== 'function') { + throw new Error( + 'OIDC IdP must provide a userinfo_endpoint in the metadata response', + ); + } done( undefined, { tokenset, userinfo },