do not rely on pkg_resources (#46476)
This commit is contained in:
parent
f8566f4619
commit
9c8e0ef4e5
7
README
7
README
|
@ -20,6 +20,13 @@ the django-mellon adapter:
|
|||
And appropriate django-mellon parameters (MELLON_PUBLIC_KEYS,
|
||||
MELLON_PRIVATE_KEY, MELLON_IDENTITY_PROVIDERS).
|
||||
|
||||
You also have to register the plugin :
|
||||
|
||||
import authentic2_auth_fedict
|
||||
|
||||
INSTALLED_APPS, TENANT_APPS, AUTHENTICATION_BACKENDS, AUTH_FRONTENDS = authentic2_auth_fedict.register(
|
||||
INSTALLED_APPS, TENANT_APPS, AUTHENTICATION_BACKENDS, AUTH_FRONTENDS
|
||||
)
|
||||
|
||||
Code Style
|
||||
----------
|
||||
|
|
|
@ -35,6 +35,9 @@ class AppConfig(django.apps.AppConfig):
|
|||
user = kwargs.get('user')
|
||||
user.backend = 'authentic2_auth_fedict.backends.FedictBackend'
|
||||
|
||||
def get_a2_plugin(self):
|
||||
return Plugin()
|
||||
|
||||
|
||||
default_app_config = 'authentic2_auth_fedict.AppConfig'
|
||||
|
||||
|
@ -45,18 +48,6 @@ class Plugin:
|
|||
|
||||
return urls.urlpatterns
|
||||
|
||||
def get_apps(self):
|
||||
return ['mellon', __name__]
|
||||
|
||||
def get_authentication_backends(self):
|
||||
return ['authentic2_auth_fedict.backends.FedictBackend']
|
||||
|
||||
def get_auth_frontends(self):
|
||||
return ['authentic2_auth_fedict.authenticators.FedictAuthenticator']
|
||||
|
||||
def get_authenticators(self):
|
||||
return ['authentic2_auth_fedict.authenticators.FedictAuthenticator']
|
||||
|
||||
def redirect_logout_list(self, request, next_url=None):
|
||||
from mellon.views import logout
|
||||
|
||||
|
@ -147,3 +138,19 @@ class Plugin:
|
|||
'field_class': fields.CountryField,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def register(installed_apps, tenant_apps, authentication_backends, auth_frontends):
|
||||
apps = []
|
||||
for app in ('mellon', 'authentic2_auth_fedict'):
|
||||
if app not in installed_apps:
|
||||
apps.append(app)
|
||||
if apps:
|
||||
installed_apps += tuple(apps)
|
||||
tenant_apps += tuple(apps)
|
||||
if 'authentic2_auth_fedict.backends.FedictBackend' not in authentication_backends:
|
||||
authentication_backends += ('authentic2_auth_fedict.backends.FedictBackend',)
|
||||
if 'authentic2_auth_fedict.authenticators.FedictAuthenticator' not in auth_frontends:
|
||||
auth_frontends += ('authentic2_auth_fedict.authenticators.FedictAuthenticator',)
|
||||
|
||||
return installed_apps, tenant_apps, authentication_backends, auth_frontends
|
||||
|
|
Loading…
Reference in New Issue