Skip to content

Mapping groups from AzureAD #13267

Closed Locked Answered by nyevess
nyevess asked this question in Help Wanted!
Discussion options

You must be logged in to vote

I find the solutions following this:
#9216
Also I'm doing some changes in custom-pipeline, I've declared on "if role ==" name of my Netbox groups that is the same as assigned in AzureAD, and some changes in code. Now it's working for me

custom-pipeline.py

from django.contrib.auth.models import Group

class AuthFailed(Exception):
    pass

def set_role(response, user, backend, *args, **kwargs):
    '''
    Get roles from JWT
    Assign user to netbox group matching role
    Also set is_superuser or is_staff for special roles 'superusers' and 'staff'
    '''
    try:
        roles = response['roles']
    except KeyError:
        user.groups.clear()
        raise AuthFailed("No role assigned…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by nyevess
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #13266 on July 25, 2023 15:48.