From 6a9009513367655dbc4123189b24fc76a9201e6b Mon Sep 17 00:00:00 2001 From: mingfu Date: Wed, 5 Apr 2023 17:55:14 +0800 Subject: [PATCH] chore: add common identify resolvers for `oidc` auth provider Signed-off-by: mingfu --- .changeset/silent-nails-bake.md | 5 +++++ plugins/auth-backend/api-report.md | 5 ++++- .../auth-backend/src/providers/oidc/provider.ts | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 .changeset/silent-nails-bake.md diff --git a/.changeset/silent-nails-bake.md b/.changeset/silent-nails-bake.md new file mode 100644 index 0000000000..1161686b34 --- /dev/null +++ b/.changeset/silent-nails-bake.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-auth-backend': patch +--- + +Add common identify resolvers for `oidc` auth provider. diff --git a/plugins/auth-backend/api-report.md b/plugins/auth-backend/api-report.md index 7515083c09..8883c3ed97 100644 --- a/plugins/auth-backend/api-report.md +++ b/plugins/auth-backend/api-report.md @@ -641,7 +641,10 @@ export const providers: Readonly<{ } | undefined, ) => AuthProviderFactory; - resolvers: never; + resolvers: Readonly<{ + emailLocalPartMatchingUserEntityName: () => SignInResolver; + emailMatchingUserEntityProfileEmail: () => SignInResolver; + }>; }>; okta: Readonly<{ create: ( diff --git a/plugins/auth-backend/src/providers/oidc/provider.ts b/plugins/auth-backend/src/providers/oidc/provider.ts index bce8ba843b..a5196f0930 100644 --- a/plugins/auth-backend/src/providers/oidc/provider.ts +++ b/plugins/auth-backend/src/providers/oidc/provider.ts @@ -44,6 +44,10 @@ import { SignInResolver, } from '../types'; import { createAuthProviderIntegration } from '../createAuthProviderIntegration'; +import { + commonByEmailLocalPartResolver, + commonByEmailResolver, +} from '../resolvers'; type PrivateInfo = { refreshToken?: string; @@ -255,4 +259,14 @@ export const oidc = createAuthProviderIntegration({ }); }); }, + resolvers: { + /** + * Looks up the user by matching their email local part to the entity name. + */ + emailLocalPartMatchingUserEntityName: () => commonByEmailLocalPartResolver, + /** + * Looks up the user by matching their email to the entity email. + */ + emailMatchingUserEntityProfileEmail: () => commonByEmailResolver, + }, });