chore: add custom claims to management token #199

Closed
argoyle wants to merge 1 commits from add-custom-claims-to-token into main
+8 -2
View File
@@ -66,7 +66,10 @@ 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 = {}
claim[adminCustomClaim] = true
const accessToken = await signToken(
addCustomClaims('management@example.org', [claim], {
iss: jwksOrigin, iss: jwksOrigin,
aud: [audience], aud: [audience],
sub: 'auth0|management', sub: 'auth0|management',
@@ -74,8 +77,10 @@ app.post('/oauth/token', async (req, res) => {
exp: date + 7200, exp: date + 7200,
azp: req.body.client_id azp: req.body.client_id
}) })
)
const idToken = await signToken({ const idToken = await signToken(
addCustomClaims('management@example.org', [claim], {
iss: jwksOrigin, iss: jwksOrigin,
aud: req.body.client_id, aud: req.body.client_id,
sub: 'auth0|management', sub: 'auth0|management',
@@ -84,6 +89,7 @@ app.post('/oauth/token', async (req, res) => {
azp: req.body.client_id, azp: req.body.client_id,
name: 'Management API' name: 'Management API'
}) })
)
debug('Signed token for management API') debug('Signed token for management API')