How to write @auth incase of user role claim in JWT has a array format

Not currently possible using arrays in Role Based Access Control.

Here was a related discussion:

That was about Booleans, but arrays are not supported either. I know I saw that somewhere here in the forum, just can’t find it right now. It might have been when @gja initially walked me through it that I picked that up.

Anyways, the only way to accomplish this right now would be to convert that array to single properties:

{
  "http://abc.xyz.com//admin": "true",
  "http://abc.xyz.com//superadmin": "true",
  "nickname": "abc",
  "name": "abc@gmail.com",
  "picture": "",
  "updated_at": "2020-09-08T12:59:14.801Z",
  "email": "abc@gmail.com",
  "email_verified": false,
  "iss": "https://xxx.us.auth0.com/"
}

Not sure though that you were not trying to use http://abc.xyz.com//roles as the claims portion of your JWT. If that was the case then it would need to look like:

{
  "http://abc.xyz.com/claims": {
    "isAdmin": "true",
    "isSuperAdmin": "true",
  },
  "nickname": "abc",
  "name": "abc@gmail.com",
  "picture": "",
  "updated_at": "2020-09-08T12:59:14.801Z",
  "email": "abc@gmail.com",
  "email_verified": false,
  "iss": "https://xxx.us.auth0.com/"
}
2 Likes