Skip to content

Add an user to a group automatically after SAML authentication #299

Closed
@tkloda

Description

@tkloda

Hello,

I'm trying to figure out a solution how to add an user to a group after this user is authenticated via SAML.
I was reading through the documentation and it seems overwriting this method might work:

from djangosaml2.backends import Saml2Backend

class MySaml2Backend(Saml2Backend):
    def save_user(self, user, *args, **kwargs):
        # Add custom logic here
        return super().save_user(user, *args, **kwargs)

My question is where should I add this piece of code in my Django project to get it working? I was trying to add it to my settings.py file, but I got an error: django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

Or is there any better solution how to add users automatically to Django groups after authentication?

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues that document features and specific configuration/use casesquestion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions