misc: set a default authentication backend priority (#45808)

This commit is contained in:
Frédéric Péters 2020-08-11 09:10:11 +02:00 committed by Benjamin Dauvergne
parent a66093a5dc
commit 7c2c6db430
4 changed files with 4 additions and 2 deletions

View File

@ -57,6 +57,7 @@ class BaseAuthenticator(object):
class LoginPasswordAuthenticator(BaseAuthenticator):
id = 'password'
submit_name = 'login-password-submit'
priority = 0
def enabled(self):
return app_settings.A2_AUTH_PASSWORD_ENABLE

View File

@ -203,7 +203,7 @@ def get_backends(setting_name='IDP_BACKENDS'):
else:
backend.name = None
if not hasattr(backend, 'priority'):
backend.priority = 0
backend.priority = 999 # backend with undefined priority go last
if backend.id and backend.id in kwargs_settings:
kwargs.update(kwargs_settings[backend.id])
backend.__dict__.update(kwargs)

View File

@ -26,7 +26,7 @@ from authentic2.authenticators import BaseAuthenticator
class OIDCAuthenticator(BaseAuthenticator):
id = 'oidc'
priority = 2
def enabled(self):
return app_settings.ENABLE and utils.has_providers()

View File

@ -27,6 +27,7 @@ from . import app_settings
class SAMLAuthenticator(BaseAuthenticator):
id = 'saml'
priority = 3
def enabled(self):
return app_settings.enable and list(get_idps())