chore: add custom claims to management token #199

Closed
argoyle wants to merge 1 commits from add-custom-claims-to-token into main
+23 -17
View File
@@ -66,24 +66,30 @@ app
app.post('/oauth/token', async (req, res) => { app.post('/oauth/token', async (req, res) => {
const date = Math.floor(Date.now() / 1000) const date = Math.floor(Date.now() / 1000)
if (req.body.grant_type === 'client_credentials' && req.body.client_id) { if (req.body.grant_type === 'client_credentials' && req.body.client_id) {
const accessToken = await signToken({ const claim = {}
iss: jwksOrigin, claim[adminCustomClaim] = true
aud: [audience], const accessToken = await signToken(
sub: 'auth0|management', addCustomClaims('management@example.org', [claim], {
iat: date, iss: jwksOrigin,
exp: date + 7200, aud: [audience],
azp: req.body.client_id sub: 'auth0|management',
}) iat: date,
exp: date + 7200,
azp: req.body.client_id
})
)
const idToken = await signToken({ const idToken = await signToken(
iss: jwksOrigin, addCustomClaims('management@example.org', [claim], {
aud: req.body.client_id, iss: jwksOrigin,
sub: 'auth0|management', aud: req.body.client_id,
iat: date, sub: 'auth0|management',
exp: date + 7200, iat: date,
azp: req.body.client_id, exp: date + 7200,
name: 'Management API' azp: req.body.client_id,
}) name: 'Management API'
})
)
debug('Signed token for management API') debug('Signed token for management API')