And then I noticed this: Auth0 only allows me to have 100 permissions per user - #4 by ayan.sen
OK, so actually in the example I copied for an action it was set to 50. Turns out the max you can have is 100.
const auth0 = require('auth0'); // 4.1.0
exports.onExecutePostLogin = async (event, api) => {
const namespace = 'https://portal.thejump.tech';
const { user } = event
const { ManagementClient } = auth0;
const management = new ManagementClient({
clientId: event.secrets.client_id,
clientSecret: event.secrets.client_secret,
domain: event.secrets.domain
});
const params = {
id: user.user_id,
page: 0,
per_page: 100, // <-- HERE
include_totals: true,
};
try {
const {
data: {
permissions:userPermissions,
}
} = await management.users.getPermissions(params);
const permissionsArr = userPermissions.map((permission) => {
return permission.permission_name;
});
api?.idToken?.setCustomClaim?.(`${namespace}/permissions`, permissionsArr);
api?.accessToken?.setCustomClaim?.(`${namespace}/permissions`, permissionsArr);
} catch (err) {
return api.access.deny(err.message);
}
}
- Can someone from Auth0 explain what you’re to do if there’s that?
- Can you make repeated calls from the client? If so, how? (Just increment page number until array empty? Or is there a flag to show ‘no more results’?)
- Also, can you cache these in any way to speed things up and avoid going over limits?
Thanks