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:
parent
d65999514f
commit
9ccda932a4
1 changed files with 10 additions and 9 deletions
|
@ -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: {
|
||||
|
|
Loading…
Reference in a new issue