Skip to content

Commit

Permalink
add regex remotion of special characters from username when creating …
Browse files Browse the repository at this point in the history
…from keycloak
  • Loading branch information
helllllllder committed May 6, 2022
1 parent cce4574 commit ba953a6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bothub/authentication/authorization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import re

from django.utils.translation import ugettext_lazy as _
from mozilla_django_oidc.auth import OIDCAuthenticationBackend
Expand Down Expand Up @@ -92,6 +93,7 @@ def create_user(self, claims):
# Override existing create_user method in OIDCAuthenticationBackend
email = claims.get("email")
username = self.get_username(claims)[:16]
username = re.sub("[^A-Za-z0-9]+", "", username)
user = self.UserModel.objects.create_user(email, username)

user.name = claims.get("name", "")
Expand Down

0 comments on commit ba953a6

Please sign in to comment.