Project

General

Profile

0001-misc-set-a-default-authentication-backend-priority-4.patch

Frédéric Péters, 11 Aug 2020 09:43 AM

Download (2.47 KB)

View differences:

Subject: [PATCH] misc: set a default authentication backend priority (#45808)

 src/authentic2/authenticators.py           | 1 +
 src/authentic2/utils/__init__.py           | 2 +-
 src/authentic2_auth_oidc/authenticators.py | 2 +-
 src/authentic2_auth_saml/authenticators.py | 1 +
 4 files changed, 4 insertions(+), 2 deletions(-)
src/authentic2/authenticators.py
57 57
class LoginPasswordAuthenticator(BaseAuthenticator):
58 58
    id = 'password'
59 59
    submit_name = 'login-password-submit'
60
    priority = 0
60 61

  
61 62
    def enabled(self):
62 63
        return app_settings.A2_AUTH_PASSWORD_ENABLE
src/authentic2/utils/__init__.py
203 203
        else:
204 204
            backend.name = None
205 205
        if not hasattr(backend, 'priority'):
206
            backend.priority = 0
206
            backend.priority = 999  # backend with undefined priority go last
207 207
        if backend.id and backend.id in kwargs_settings:
208 208
            kwargs.update(kwargs_settings[backend.id])
209 209
        backend.__dict__.update(kwargs)
src/authentic2_auth_oidc/authenticators.py
26 26

  
27 27
class OIDCAuthenticator(BaseAuthenticator):
28 28
    id = 'oidc'
29

  
29
    priority = 2
30 30

  
31 31
    def enabled(self):
32 32
        return app_settings.ENABLE and utils.has_providers()
src/authentic2_auth_saml/authenticators.py
27 27

  
28 28
class SAMLAuthenticator(BaseAuthenticator):
29 29
    id = 'saml'
30
    priority = 3
30 31

  
31 32
    def enabled(self):
32 33
        return app_settings.enable and list(get_idps())
33
-