mcueto / djangorestframework-auth0

Library to simply use Auth0 token authentication in DRF within djangorestframework-jwt
MIT License
91 stars 19 forks source link

roles not in app_metadata #40

Closed Calion54 closed 6 years ago

Calion54 commented 6 years ago

Hi,

I use authorization extension, I inherit from your class "HasRoleBasePermission" but it throws an exception. Indeed, the array of the roles are not in the field "app_metadata" but directly at the first level of the object payload. Is it normal for me to have the array at this level ?

Best regards,

mcueto commented 6 years ago

Which scope are you setting in your lockjs config??? Example config:

var options = {
  auth: {
    params: {scope: 'openid email user_metadata app_metadata picture'},
  }
};
Calion54 commented 6 years ago

Yes, I tried with your config but there is no change to the payload structure. I do not use the lock but directly auth0-js

Calion54 commented 6 years ago

"If your authorization context is large (for example, the user might belong to many groups or have been granted many permissions), you might find it useful to store some of the authorization content in the users' profiles. This allows you to store less information in the token, which means you're less likely to see performance-related issues or even problems with token issuance. Persistence is the process by which you store groups, roles, and permissions information in the users' profiles.

The data will be stored in the user's app_metadata field, and you can then use the Management API or the Dashboard to retrieve this information after the user has logged in." (https://auth0.com/docs/extensions/authorization-extension/v2/implementation/configuration)

So, actually, the roles are fine in the app_metadata object but I have an extra object level. He adds me "Authorization"

capture d ecran 2017-12-13 a 17 38 43

Are you sure that the library is still up to date with their "Authorization Extension" system ?

Calion54 commented 6 years ago

Fix with #42