diff --git a/.changeset/honest-rockets-sit.md b/.changeset/honest-rockets-sit.md new file mode 100644 index 0000000000..e63884bcb4 --- /dev/null +++ b/.changeset/honest-rockets-sit.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-auth-backend': minor +--- + +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/plugins/auth-backend/src/providers/google/provider.ts b/plugins/auth-backend/src/providers/google/provider.ts index 90e68c6f9c..44c22f757e 100644 --- a/plugins/auth-backend/src/providers/google/provider.ts +++ b/plugins/auth-backend/src/providers/google/provider.ts @@ -227,7 +227,7 @@ const googleDefaultSignInResolver: SignInResolver = async ( } const token = await ctx.tokenIssuer.issueToken({ - claims: { sub: userId, ent: [`user:default/${userId}`] }, + claims: { sub: `user:default/${userId}`, ent: [`user:default/${userId}`] }, }); return { id: userId, token }; diff --git a/plugins/auth-backend/src/providers/oidc/provider.ts b/plugins/auth-backend/src/providers/oidc/provider.ts index 5ffbf070bd..0c820648e4 100644 --- a/plugins/auth-backend/src/providers/oidc/provider.ts +++ b/plugins/auth-backend/src/providers/oidc/provider.ts @@ -221,7 +221,10 @@ export const oAuth2DefaultSignInResolver: SignInResolver< } const userId = profile.email.split('@')[0]; const token = await ctx.tokenIssuer.issueToken({ - claims: { sub: userId, ent: [`user:default/${userId}`] }, + claims: { + sub: `user:default/${userId}`, + ent: [`user:default/${userId}`], + }, }); return { id: userId, token }; };