New Permissions added to role not updating

As the title says, I’ve got perms attributed to a role and a user with that role but when I retrieve the user the are not showing:



{
  "https://portal.thejump.tech/roles": [
    "admin",
    "Admin (Designs)",
    "Admin Shop"
  ],
  "https://portal.thejump.tech/app_metadata": {
    "admin": false
  },
  "https://portal.thejump.tech/user_metadata": {},
  "https://portal.thejump.tech/permissions": [
    "admin",
    "baskets:create",
    "baskets:delete",
    "baskets:read",
    "baskets:update",
    "course:datasci",
    "course:data-science:full-time",
    "course:data-science:part-time",
    "course:data-science:self-paced",
    "course:devops",
    "course:devops:full-time",
    "course:devops:part-time",
    "course:devops:self-paced",
    "course:web",
    "course:web:full-time",
    "course:web:part-time",
    "course:web:self-paced",
    "create:designs",
    "delete:designs",
    "homework:create",
    "homework:delete",
    "homework:read",
    "homework:update",
    "lesson:AJAX",
    "lesson:Animation",
    "lesson:Array-Methods",
    "lesson:Audio-Video",
    "lesson:Auth",
    "lesson:Build-Building-Common-Features",
    "lesson:Build-DOM-App",
    "lesson:Build-Figma-4-Card-Feature\"",
    "lesson:Build-Full-Stack-Application",
    "lesson:Build-React-SPA",
    "lesson:Build-Techs",
    "lesson:Build-Todo-Console-App",
    "lesson:CI-CD",
    "lesson:Command-Line",
    "lesson:Context-and-MUI",
    "lesson:CSS3",
    "lesson:CSS-Declarations",
    "lesson:CSS-Endgame",
    "lesson:CSS-Frameworks",
    "lesson:CSS-Selectors",
    "lesson:Data-Types-Objects",
    "lesson:Data-Types-Primitives",
    "lesson:Dates-and-Regex",
    "lesson:Docker",
    "lesson:Ecosystem-Router-and-React-Hook-Forms",
    "lesson:ES6",
    "lesson:Functions"
  ],
  "given_name": "James",
  "family_name": "Sherry",
  "nickname": "james.sherry",
  "name": "James Sherry",
  "picture": "https://lh3.googleusercontent.com/a/ACg8ocKkcxKINDNI90PB5RPOpG3MrKyXIS72J2WelX-Ih4dbMg=s96-c",
  "locale": "en-GB",
  "updated_at": "2023-11-22T00:53:37.861Z",
  "email": "james.sherry@thejump.tech",
  "email_verified": true,
  "sub": "google-oauth2|11347         759809880",
  "sid": "5OWnhZ_HexIIVYkZ1c1jxa1TeMqFHt8"
}

I’ve logged in and out multiple times and in different browsers; I’ve tried making a request for a refresh token and got back new tokens successfully and then re-authing but to no avail. (The role is also not present in the Management API explorer.)

Really not sure how to prod the system to make it look again…

Any help greatly appreciated!

Hmmm. Just noticed there are 50 perms there. I looked at limits and it told me there was 1000 perms per user (Entity Limit Policy). Is there a limit? Or is the retrieval paginated?

And then I noticed this: Auth0 only allows me to have 100 permissions per user - #4 by ayan.sen :roll_eyes:

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