From 26c7fca6bef15460b06ce9039a75bbe699a2ec6f Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 27 Jan 2022 10:52:00 +0100 Subject: [PATCH] auth-backend: prettier + changeset tweak Signed-off-by: Patrik Oldsberg --- .changeset/honest-rockets-sit.md | 2 +- ADOPTERS.md | 2 +- .../src/providers/oidc/provider.ts | 31 ++++++++++--------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.changeset/honest-rockets-sit.md b/.changeset/honest-rockets-sit.md index 9992837b32..e63884bcb4 100644 --- a/.changeset/honest-rockets-sit.md +++ b/.changeset/honest-rockets-sit.md @@ -2,4 +2,4 @@ '@backstage/plugin-auth-backend': minor --- -Google and OIDC token subs will be full entity ref +The `sub` claim in Backstage tokens generated by the default Google and OIDC sign-in resolvers are now full entity references of the format `:/`. diff --git a/ADOPTERS.md b/ADOPTERS.md index b95e20757d..21b5b131a9 100644 --- a/ADOPTERS.md +++ b/ADOPTERS.md @@ -84,4 +84,4 @@ | [Livspace](https://www.livspace.com) | [Praveen Kumar](https://github.com/praveen-livspace) | Developer portal, service catalog, tech docs, API docs and plugins | | [Just Eat Takeaway](https://www.justeattakeaway.com) | [Kim Wilson](https://github.com/kwilson541) | Our developer portal which centralises applications, reduces cognitive load and provides teams insights. | | [Hopin](https://hopin.com) | [Vladimir Glafirov](https://github.com/vglafirov), [Chloe Lee](https://github.com/msfuko) | Developer portal to streamline the development practices. Integrated with service catalog, software templates, application monitoring, tech docs and plugins. | -| [HBO Max](https://hbomax.com) | [@mdb](https://github.com/mdb), [@nesta219](https://github.com/nesta219), [@nmische](https://github.com/nmische), [@hbomark](https://github.com/hbomark) | Developer portal hosting service catalog and API documentation, as well as cloud infrastructure details, operational visibility tools, and a custom plugin for browsing notable platform change events, such as deployments and configuration updates. | +| [HBO Max](https://hbomax.com) | [@mdb](https://github.com/mdb), [@nesta219](https://github.com/nesta219), [@nmische](https://github.com/nmische), [@hbomark](https://github.com/hbomark) | Developer portal hosting service catalog and API documentation, as well as cloud infrastructure details, operational visibility tools, and a custom plugin for browsing notable platform change events, such as deployments and configuration updates. | diff --git a/plugins/auth-backend/src/providers/oidc/provider.ts b/plugins/auth-backend/src/providers/oidc/provider.ts index cff7438da1..0c820648e4 100644 --- a/plugins/auth-backend/src/providers/oidc/provider.ts +++ b/plugins/auth-backend/src/providers/oidc/provider.ts @@ -211,22 +211,23 @@ export class OidcAuthProvider implements OAuthHandlers { } } -export const oAuth2DefaultSignInResolver: SignInResolver = - async (info, ctx) => { - const { profile } = info; +export const oAuth2DefaultSignInResolver: SignInResolver< + OidcAuthResult +> = async (info, ctx) => { + const { profile } = info; - if (!profile.email) { - throw new Error('Profile contained no email'); - } - const userId = profile.email.split('@')[0]; - const token = await ctx.tokenIssuer.issueToken({ - claims: { - sub: `user:default/${userId}`, - ent: [`user:default/${userId}`], - }, - }); - return { id: userId, token }; - }; + if (!profile.email) { + throw new Error('Profile contained no email'); + } + const userId = profile.email.split('@')[0]; + const token = await ctx.tokenIssuer.issueToken({ + claims: { + sub: `user:default/${userId}`, + ent: [`user:default/${userId}`], + }, + }); + return { id: userId, token }; +}; /** * OIDC provider callback options. An auth handler and a sign in resolver