Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend the functionality of custom OIDC_USERNAME_ALGO to using claims #492

Closed
EduardRosert opened this issue Jun 1, 2023 · 1 comment
Closed

Comments

@EduardRosert
Copy link
Contributor

At the moment, configuring a custom user name also via the OIDC_USERNAME_ALGO environment variable currently limits the username generation to usernames based on the user's email from the oidc claims.

In auth.py:

    def get_username(self, claims):
        """Generate username based on claims."""
        # bluntly stolen from django-browserid
        # https://github.com/mozilla/django-browserid/blob/master/django_browserid/auth.py
        username_algo = self.get_settings("OIDC_USERNAME_ALGO", None)

        if username_algo:
            if isinstance(username_algo, str):
                username_algo = import_string(username_algo)
            return username_algo(claims.get("email"))  # <-- this could accept claims as an argument to make it more general

It would be useful make the custom user name generation more general by also passing the claims, maybe in a backwards compatible manner.

A related issue that might be solved with the proposed change as well would be #482.

@akatsoulas
Copy link
Collaborator

Fixed via #508

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants