Peter-Slump / django-keycloak

Django app to add Keycloak support to your project.
MIT License
129 stars 121 forks source link

Django admin not working when AUTHENTICATION_BACKENDS not set properly #50

Open kristall opened 4 years ago

kristall commented 4 years ago

Under https://django-keycloak.readthedocs.io/en/latest/index.html#setup is the point

AUTHENTICATION_BACKENDS = [
    ...
    'django_keycloak.auth.backends.KeycloakAuthorizationCodeBackend',
]

but in an "vanilla" settings file is no AUTHENTICATION_BACKENDS so the ... need to be replace with the default value (see https://docs.djangoproject.com/en/3.1/ref/settings/#auth): 'django.contrib.auth.backends.ModelBackend',, so that it looks like this

AUTHENTICATION_BACKENDS = [
    'django.contrib.auth.backends.ModelBackend',
    'django_keycloak.auth.backends.KeycloakAuthorizationCodeBackend',
]

else the django superuser can not login to the django admin. I banged my head for 2 hours against that, so I leave a clue here for others ...

cjy543731778 commented 4 years ago

Under https://django-keycloak.readthedocs.io/en/latest/index.html#setup is the point

AUTHENTICATION_BACKENDS = [
   ...
   'django_keycloak.auth.backends.KeycloakAuthorizationCodeBackend',
]

but in an "vanilla" settings file is no AUTHENTICATION_BACKENDS so the ... need to be replace with the default value (see https://docs.djangoproject.com/en/3.1/ref/settings/#auth): 'django.contrib.auth.backends.ModelBackend',, so that it looks like this

AUTHENTICATION_BACKENDS = [
    'django.contrib.auth.backends.ModelBackend',
    'django_keycloak.auth.backends.KeycloakAuthorizationCodeBackend',
]

else the django superuser can not login to the django admin. I banged my head for 2 hours against that, so I leave a clue here for others ...

Thank you very much.

bowerta commented 4 years ago

Under https://django-keycloak.readthedocs.io/en/latest/index.html#setup is the point

AUTHENTICATION_BACKENDS = [
   ...
   'django_keycloak.auth.backends.KeycloakAuthorizationCodeBackend',
]

but in an "vanilla" settings file is no AUTHENTICATION_BACKENDS so the ... need to be replace with the default value (see https://docs.djangoproject.com/en/3.1/ref/settings/#auth): 'django.contrib.auth.backends.ModelBackend',, so that it looks like this

AUTHENTICATION_BACKENDS = [
    'django.contrib.auth.backends.ModelBackend',
    'django_keycloak.auth.backends.KeycloakAuthorizationCodeBackend',
]

else the django superuser can not login to the django admin. I banged my head for 2 hours against that, so I leave a clue here for others ...

Thanks, this was helpful