Last active
August 29, 2015 14:09
-
-
Save eugeniop/b778915e9f4d1cecd0b8 to your computer and use it in GitHub Desktop.
JWT in rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function (user, context, callback) { | |
var CLIENT_SECRET = 'TARGET_API_CLIENT_SECRET'; // Target API Client secret | |
var CLIENT_ID = 'TARGET_API_CLIENT_ID'; | |
var jwt_user = { | |
user_id: user.id, | |
email: user.email, | |
name: user.name | |
}; | |
var options = { | |
expiresInMinutes: 600, //should match the app's expiration | |
audience: TARGET_CLIENT_ID, | |
subject: user.user.id | |
issuer: 'THIS AUTH SERVER' //e.g. "https://eugeniopace.auth0.com" | |
}; | |
user.id_token = jwt.sign(jwt_user, new Buffer(TARGET_API_CLIENT_SECRET, 'base64'), options); | |
callback(null, user, context); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment