KITPraktomatTeam/Praktomat

multiple but different defined d.AUTHENTICATION_BACKENDS in settings/defaults.py

ifrh opened this issue · 2 comments

ifrh commented

In Praktomat/src/settings/defauls.py there a two places where d.AUTHENTICATION_BACKENDS is defined in different ways:

d.AUTH_BACKEND = 'django.contrib.auth.backends.AllowAllUsersModelBackend'
d.AUTHENTICATION_BACKENDS = (d.AUTH_BACKEND,)

d.AUTHENTICATION_BACKENDS = (
'accounts.ldap_auth.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
)

This could be a problem, if these settings are not overwritten via local.py, because

Above bulletpoints are taken from Django-Docs:

  1. https://docs.djangoproject.com/en/4.0/topics/auth/customizing/#authentication-backends

  2. https://docs.djangoproject.com/en/1.11/topics/auth/customizing/#authorization-for-inactive-users

ifrh commented

@hannesbraun @ratefuchs I think accounts.ldap_auth.LDAPBackend should be the first and django.contrib.auth.backends.AllowAllUsersModelBackend should be the second entry in d.AUTHENTICATION_BACKENDS.
And there is no need to mention django.contrib.auth.backends.ModelBackend inside settings/defaults.py.

I agree with that. The ModelBackend should be replaced with the AllowAllUsersModelBackend. For the sake of simplicity, it's probably also a good idea to merge those two parts into one where the AUTHENTICATION_BACKENDS are set.