mozilla / mozilla-django-oidc

A django OpenID Connect library
https://mozilla-django-oidc.readthedocs.io
Mozilla Public License 2.0
444 stars 166 forks source link

Access JWT payload #538

Closed eyk107 closed 2 months ago

eyk107 commented 2 months ago

Hi,

I'm using the following code to add the group during the user creation but there group-information is missing in the claims-variable:

`class MyOIDCAB(OIDCAuthenticationBackend):

def create_user(self, claims):

    user = super(MyOIDCAB, self).create_user(claims)

    usergroup = claims.get('roles', '')

    if usergroup:

      for i_group in usergroup:

        try:

            group = Group.objects.get(name=i_group)

            if group:

                user.groups.add(group)

        except Group.DoesNotExist:

            pass

    user.save()

    return user`

I tried to check the token via Postman and after the decoding of the id_token I was able to read the group. Is there any easy way to grep the payload of the id_token?

eyk107 commented 2 months ago

https://github.com/mozilla/mozilla-django-oidc/issues/346