Tuesday, October 5, 2021

Keycloak & Django Setup Error - "UNIQUE constraint failed: auth_user.username" & usernames are being hashed


I am setting up keycloak for a django project and this is the error I receive:


IntegrityError at /oidccallback/UNIQUE constraint failed: auth_user.usernameRequest Method:
GET

It looks like when I log in, keycloak tries to create my user again, even though my user is in the database.

Also, my usernames are hashed in the auth_user table in the database.

This is my code in my settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

I also tried setting the OIDC_CREATE_USER setting to False but that only prevented django from from detecting login sessions (which still were created properly).

Any ideas on what is going wrong and how I can fix it?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6be23087-ab54-4bfb-8a57-1bc8fbe35359n%40googlegroups.com.

No comments:

Post a Comment