Last active
June 4, 2019 11:59
-
-
Save Tanver-Hasan/d09e09eedaac2e82c929dc083781ebec to your computer and use it in GitHub Desktop.
This file contains hidden or 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) { | |
// console.log(JSON.stringify(user)); | |
// console.log(JSON.stringify(context)); | |
const audience = context.request && context.request.body && context.request.body.audience ? context.request.body.audience : null; | |
console.log(audience); | |
if (audience === "API IDENTIFIER" ){ | |
console.log("Checking client"); | |
const whitelistClient = ["Client ID","Client ID"]; | |
const isValidClient= whitelistClient.some( | |
function(client){ | |
const clientInRequest= context.clientID; | |
console.log(clientInRequest); | |
return client === clientInRequest; | |
} | |
); | |
console.log(isValidClient); | |
if (!isValidClient){ | |
console.log("Invalid client"); | |
return callback(new UnauthorizedError('Access denied : Not a valid client for the audience')); | |
} | |
} | |
callback(null, user, context); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://auth0.com/docs/rules/references/context-object