0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00

feat(core): add custom claims to id token (#911)

This commit is contained in:
Xiao Yijun 2022-05-20 22:37:47 +08:00 committed by GitHub
parent d65999514f
commit 9ccda932a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -84,19 +84,20 @@ export default async function initOidc(app: Koa): Promise<Provider> {
},
// https://github.com/panva/node-oidc-provider/blob/main/recipes/client_based_origins.md
clientBasedCORS: (_, origin, client) => isOriginAllowed(origin, client.metadata()),
claims: {
openid: ['sub', 'name', 'avatar', 'custom_data'],
},
findAccount: async (ctx, sub) => {
await findUserById(sub);
const { name, avatar, customData } = await findUserById(sub);
return {
accountId: sub,
claims: async (use, scope, claims, rejected) => {
console.log('use:', use);
console.log('scope:', scope);
console.log('claims:', claims);
console.log('rejected:', rejected);
return { sub };
},
claims: async () => ({
sub,
name,
avatar,
custom_data: customData,
}),
};
},
ttl: {