oidc and googld subs will be full entity refs

Signed-off-by: elonj <elonj@spotify.com>
This commit is contained in:
elonj
2022-01-26 17:27:32 -05:00
parent 867d44c82e
commit 80b9027eb7
2 changed files with 16 additions and 14 deletions
@@ -227,7 +227,7 @@ const googleDefaultSignInResolver: SignInResolver<OAuthResult> = 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 };
@@ -211,20 +211,22 @@ export class OidcAuthProvider implements OAuthHandlers {
}
}
export const oAuth2DefaultSignInResolver: SignInResolver<
OidcAuthResult
> = 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: 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