-
Notifications
You must be signed in to change notification settings - Fork 41
Configuration
To run the dashboard you first need to create an application in Auth0 in which you set the Allowed Callback URL to the URL of your application (eg: http://localhost:2500/).
Then you'll need to go to the APIv2 explorer and generate a token with the following permissions:
- read:clients
- read:users
- read:users_app_metadata
- update:users_app_metadata
- delete:users_app_metadata
- create:users_app_metadata
Finally add the following settings as environment variables or in a config.json file:
{
"AUTH0_DOMAIN": "you.auth0.com",
"AUTH0_CLIENT_ID": "YOUR_CLIENT_ID",
"AUTH0_CLIENT_SECRET": "YOUR_CLIENT_SECRET",
"AUTH0_APIV2_TOKEN": "eyJhbGc...",
"PORT": 2500,
"ENV": "development" (or "production")
}
Note: For now all of this data is stored in a config.json file.
Create a rule in Auth0 that calls out to the dashboard's API and adds the permissions to the user's token:
function (user, context, callback) {
if (!user.roles || user.roles.length === 0) {
return callback(null, user, context);
}
request.post({
url: configuration.PERMISSIONS_API_BASE_URL +
'/api/apps/' + context.clientID + '/permissions',
json: {
roles: user.roles
},
timeout: 5000
}, function(err, response, body) {
if (err)
return callback(new Error(err));
user.permissions = body.permissions;
return callback(null, user, context);
});
}
In order for this to work add a configuration setting in the Auth0 dashboard that points to the base url of the dashboard. Eg:
PERMISSIONS_API_BASE_URL = https://fabrikam-roles-permissions.azurewebsites.net
Add a 'data.json' to in your root file.
{
"permissions": [],
"roles": []
}