Projet

Général

Profil

0003-multifactor-totp-turn-plugin-into-app.patch

Valentin Deniaud, 12 juillet 2019 15:03

Télécharger (11,1 ko)

Voir les différences:

Subject: [PATCH] multifactor-totp: turn plugin into app

 setup.py                                          |  1 -
 .../auth2_multifactor/auth_oath/__init__.py       | 15 ---------------
 src/authentic2/settings.py                        |  9 +++++++--
 src/authentic2/urls.py                            |  1 +
 .../__init__.py                                   |  0
 .../app_settings.py                               |  0
 .../authenticators.py                             |  0
 .../auth_oath => authentic2_mfa_totp}/forms.py    |  0
 .../migrations/0001_initial.py                    |  0
 src/authentic2_mfa_totp/migrations/__init__.py    |  0
 .../auth_oath => authentic2_mfa_totp}/models.py   |  0
 .../templates/auth_oath/disable_confirm.html      |  0
 .../templates/auth_oath/generate_confirm.html     |  0
 .../templates/auth_oath/qrcode.html               |  0
 .../templates/auth_oath/totp_enable.html          |  0
 .../templates/auth_oath/totp_form.html            |  0
 .../templates/auth_oath/totp_profile.html         |  0
 .../auth_oath/totp_recovery_display.html          |  0
 .../templates/auth_oath/totp_recovery_form.html   |  0
 .../auth_oath => authentic2_mfa_totp}/urls.py     |  0
 .../auth_oath => authentic2_mfa_totp}/utils.py    |  0
 .../auth_oath => authentic2_mfa_totp}/views.py    |  0
 22 files changed, 8 insertions(+), 18 deletions(-)
 delete mode 100644 src/authentic2/auth2_multifactor/auth_oath/__init__.py
 rename src/{authentic2/auth2_multifactor/auth_oath/migrations => authentic2_mfa_totp}/__init__.py (100%)
 rename src/{authentic2/auth2_multifactor/auth_oath => authentic2_mfa_totp}/app_settings.py (100%)
 rename src/{authentic2/auth2_multifactor/auth_oath => authentic2_mfa_totp}/authenticators.py (100%)
 rename src/{authentic2/auth2_multifactor/auth_oath => authentic2_mfa_totp}/forms.py (100%)
 rename src/{authentic2/auth2_multifactor/auth_oath => authentic2_mfa_totp}/migrations/0001_initial.py (100%)
 create mode 100644 src/authentic2_mfa_totp/migrations/__init__.py
 rename src/{authentic2/auth2_multifactor/auth_oath => authentic2_mfa_totp}/models.py (100%)
 rename src/{authentic2/auth2_multifactor/auth_oath => authentic2_mfa_totp}/templates/auth_oath/disable_confirm.html (100%)
 rename src/{authentic2/auth2_multifactor/auth_oath => authentic2_mfa_totp}/templates/auth_oath/generate_confirm.html (100%)
 rename src/{authentic2/auth2_multifactor/auth_oath => authentic2_mfa_totp}/templates/auth_oath/qrcode.html (100%)
 rename src/{authentic2/auth2_multifactor/auth_oath => authentic2_mfa_totp}/templates/auth_oath/totp_enable.html (100%)
 rename src/{authentic2/auth2_multifactor/auth_oath => authentic2_mfa_totp}/templates/auth_oath/totp_form.html (100%)
 rename src/{authentic2/auth2_multifactor/auth_oath => authentic2_mfa_totp}/templates/auth_oath/totp_profile.html (100%)
 rename src/{authentic2/auth2_multifactor/auth_oath => authentic2_mfa_totp}/templates/auth_oath/totp_recovery_display.html (100%)
 rename src/{authentic2/auth2_multifactor/auth_oath => authentic2_mfa_totp}/templates/auth_oath/totp_recovery_form.html (100%)
 rename src/{authentic2/auth2_multifactor/auth_oath => authentic2_mfa_totp}/urls.py (100%)
 rename src/{authentic2/auth2_multifactor/auth_oath => authentic2_mfa_totp}/utils.py (100%)
 rename src/{authentic2/auth2_multifactor/auth_oath => authentic2_mfa_totp}/views.py (100%)
setup.py
176 176
              'authentic2-idp-oidc = authentic2_idp_oidc:Plugin',
177 177
              'authentic2-provisionning-ldap = authentic2_provisionning_ldap:Plugin',
178 178
              'authentic2-auth-fc = authentic2_auth_fc:Plugin',
179
              'authentic2-auth-oath = authentic2.auth2_multifactor.auth_oath:Plugin',
180 179
          ],
181 180
      })
src/authentic2/auth2_multifactor/auth_oath/__init__.py
1
class Plugin(object):
2
    def get_before_urls(self):
3
        from . import app_settings
4
        from django.conf.urls import include, url
5
        from authentic2.decorators import setting_enabled, required
6

  
7
        return required(
8
            setting_enabled('ENABLE', settings=app_settings),
9
            [url(r'^accounts/authenticators/totp/', include(__name__ + '.urls'))])
10

  
11
    def get_apps(self):
12
        return [__name__]
13

  
14
    def get_authenticators(self):
15
        return ['authentic2.auth2_multifactor.auth_oath.authenticators.TOTPAuthenticator']
src/authentic2/settings.py
145 145
    'xstatic.pkg.jquery',
146 146
    'xstatic.pkg.jquery_ui',
147 147
    'xstatic.pkg.select2',
148
    'authentic2_mfa_totp',
148 149
)
149 150

  
150 151
INSTALLED_APPS = tuple(plugins.register_plugins_installed_apps(INSTALLED_APPS))
......
174 175
# Authentication settings
175 176
###########################
176 177
AUTH_USER_MODEL = 'custom_user.User'
177
AUTH_FRONTENDS = plugins.register_plugins_authenticators((
178
    'authentic2.authenticators.LoginPasswordAuthenticator',))
178
AUTH_FRONTENDS = [
179
    'authentic2_mfa_totp.authenticators.TOTPAuthenticator',
180
]
181
AUTH_FRONTENDS.extend(plugins.register_plugins_authenticators((
182
    'authentic2.authenticators.LoginPasswordAuthenticator',
183
)))
179 184

  
180 185
###########################
181 186
# RBAC settings
src/authentic2/urls.py
119 119
    url(r'^idp/', include('authentic2.idp.urls')),
120 120
    url(r'^manage/', include('authentic2.manager.urls')),
121 121
    url(r'^api/', include('authentic2.api_urls')),
122
    url(r'^totp/', include('authentic2_mfa_totp.urls')),
122 123
]
123 124

  
124 125
try: