urbanplatform / django-keycloak-auth

Middleware to allow authorization using Keycloak and Django for django-rest-framework (DRF). This package should only be used in projects starting from scratch, since it overrides the users' management.
MIT License
32 stars 14 forks source link

[bug] user with no email in keycloak are failing to login in Django #46

Closed yalattas closed 1 year ago

yalattas commented 1 year ago

Describe the bug A user has been registered to keyCloak and has username and password but no email (username can be phone number OR a string). if user attempts to login into Django backend, Django is throwing IntegrityError

To Reproduce Steps to reproduce the behavior:

  1. create a user in KeyCloak but don't assign an email. make it optional
  2. generate a credentials for that user
  3. visit Django admin page EX: http://localhost:8000/admin/
  4. put username and password same as KeyCloak
  5. You will see the error

workaround:

  1. after seeing the error, Go back to keyCloak and assign any email to that user.
  2. Now you can login to Django admin

Expected behavior Allowing access to Django admin with no email

Screenshots image

Desktop (please complete the following information):

Additional context Main dependencies

djangorestframework==3.14.0
Django==4.1.3
django-uw-keycloak==2.0.1
python-keycloak==2.6.0
moritz89 commented 1 year ago

Probably use AUTH_USER_MODEL = "django_keycloak.KeycloakUser" in your settings. However, this will limit functionality of saving user info into the DB. As your use-case is not a requirement of the core developers, I do not think they will take it up, but if you submit a quality MR, they're open to improvements.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 7 days with no activity.