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

IntegrityError null value in column "first_name" of relation "users_keycloakprofile" violates not null constraint #40

Closed susanacmdias closed 2 years ago

susanacmdias commented 2 years ago

Describe the bug After being logged in for some time, the user gets a 500 error, "null value in column "first_name" of relation "users_keycloakprofile" violates not null cosntraint". It's not explicit, after debbuging we could find out that the token has expired, because if we ask for a new one it works. This doesn't happen every time, just every now and then.

To Reproduce Steps to reproduce the behavior:

  1. Login with your credentials in a Mobile App calling a Django API served by this library
  2. Remain in the UI and allow your token to expire
  3. Click somewhere that calls the Django API
  4. See error crashing the Django project

Expected behavior When the token is expired, we want to receive a 401 Not Authorized, however we get a 500(null value in column "first_name" of relation "users_keycloakprofile" violates not null cosntraint)

Screenshots 198083275-5af6fb7d-ff2d-4ddd-bf03-5d1018cd416e

Desktop (please complete the following information):

diogosilva30 commented 2 years ago

@moritz89 Could this be the same issue as https://github.com/urbanplatform/django-keycloak-auth/issues/38 ? We need to check if this is solved in v2.

EDIT: For what is reported by @moritz89. This issue is probably gone in our version 2. We are close to release. Maybe we should add tests for this issue

moritz89 commented 2 years ago

I've added a test that approximates this issue: tests/test_site/test_app/tests/test_middleware.py:TestErrorHandling:test_invalid_auth_token. @Sudms Could you test it with that branch / when it is released?

moritz89 commented 2 years ago

@Sudms Could you check if the bug still persists?

moritz89 commented 2 years ago

I'm closing this issue due to inactivity. Feel free to open it as required.