From 8aa061464838f7cd4e3df11075fa03f53a0a456b Mon Sep 17 00:00:00 2001
From: Emmanuel Cazenave <ecazenave@entrouvert.com>
Date: Tue, 23 Jun 2020 14:29:12 +0200
Subject: [PATCH] remove authentic2_auth_fc from plugin system (#44369)

---
 setup.py                           |  5 ---
 src/authentic2/settings.py         |  3 ++
 src/authentic2/urls.py             |  2 ++
 src/authentic2_auth_fc/__init__.py | 51 +++++++++++-------------------
 4 files changed, 24 insertions(+), 37 deletions(-)

diff --git a/setup.py b/setup.py
index 3676d763..a7191f2c 100755
--- a/setup.py
+++ b/setup.py
@@ -166,9 +166,4 @@ setup(name="authentic2",
           'install_lib': install_lib,
           'compile_translations': compile_translations,
           'sdist': sdist,
-      },
-      entry_points={
-          'authentic2.plugin': [
-              'authentic2-auth-fc = authentic2_auth_fc:Plugin',
-          ],
       })
diff --git a/src/authentic2/settings.py b/src/authentic2/settings.py
index 9a785d1b..bbef08e6 100644
--- a/src/authentic2/settings.py
+++ b/src/authentic2/settings.py
@@ -129,6 +129,7 @@ INSTALLED_APPS = (
     'django_select2',
     'django_tables2',
     'mellon',
+    'authentic2_auth_fc',
     'authentic2_auth_saml',
     'authentic2_auth_oidc',
     'authentic2_idp_cas',
@@ -162,6 +163,7 @@ AUTHENTICATION_BACKENDS = (
     'django_rbac.backends.DjangoRBACBackend',
     'authentic2_auth_saml.backends.SAMLBackend',
     'authentic2_auth_oidc.backends.OIDCBackend',
+    'authentic2_auth_fc.backends.FcBackend',
 )
 AUTHENTICATION_BACKENDS = plugins.register_plugins_authentication_backends(AUTHENTICATION_BACKENDS)
 CSRF_FAILURE_VIEW = 'authentic2.views.csrf_failure_view'
@@ -183,6 +185,7 @@ AUTH_USER_MODEL = 'custom_user.User'
 AUTH_FRONTENDS = (
     'authentic2_auth_saml.authenticators.SAMLAuthenticator',
     'authentic2_auth_oidc.authenticators.OIDCAuthenticator',
+    'authentic2_auth_fc.authenticators.FcAuthenticator',
 ) + plugins.register_plugins_authenticators((
     'authentic2.authenticators.LoginPasswordAuthenticator',))
 
diff --git a/src/authentic2/urls.py b/src/authentic2/urls.py
index abdd0be5..bb3d7f0a 100644
--- a/src/authentic2/urls.py
+++ b/src/authentic2/urls.py
@@ -25,6 +25,7 @@ from django.views.static import serve as media_serve
 
 from . import plugins, views
 from authentic2.decorators import setting_enabled, required, lasso_required
+import authentic2_auth_fc.urls
 import authentic2_auth_oidc.urls
 import authentic2_auth_saml.urls
 import authentic2_idp_cas.app_settings
@@ -168,6 +169,7 @@ authentic2_idp_cas_urls = required(
 )
 
 urlpatterns = (
+    authentic2_auth_fc.urls.urlpatterns +
     authentic2_idp_oidc.urls.urlpatterns +
     authentic2_idp_cas_urls +
     authentic2_auth_oidc.urls.urlpatterns +
diff --git a/src/authentic2_auth_fc/__init__.py b/src/authentic2_auth_fc/__init__.py
index 2cea0430..ebccf462 100644
--- a/src/authentic2_auth_fc/__init__.py
+++ b/src/authentic2_auth_fc/__init__.py
@@ -20,38 +20,6 @@ from . import app_settings
 import django.apps
 
 
-class Plugin(object):
-    def get_before_urls(self):
-        from . import urls
-        return urls.urlpatterns
-
-    def get_apps(self):
-        return [__name__]
-
-    def get_authentication_backends(self):
-        return ['authentic2_auth_fc.backends.FcBackend']
-
-    def get_authenticators(self):
-        return ['authentic2_auth_fc.authenticators.FcAuthenticator']
-
-    def redirect_logout_list(self, request, **kwargs):
-        from django.urls import reverse
-        from . import utils
-
-        url = utils.build_logout_url(request, next_url=reverse('auth_logout'))
-        # url is assumed empty if no active session on the OP.
-        if url:
-            return [url]
-        return []
-
-    def registration_form_prefill(self, request):
-        from . import utils
-
-        if app_settings.enable_registration_form_prefill:
-            return [utils.get_mapped_attributes(request)]
-        return []
-
-
 class AppConfig(django.apps.AppConfig):
 
     name = __name__
@@ -105,5 +73,24 @@ class AppConfig(django.apps.AppConfig):
                     return False
         return True
 
+    def redirect_logout_list(self, request, **kwargs):
+        from django.urls import reverse
+        from . import utils
+
+        url = utils.build_logout_url(request, next_url=reverse('auth_logout'))
+        # url is assumed empty if no active session on the OP.
+        if url:
+            return [url]
+        return []
+
+    def registration_form_prefill(self, request):
+        from . import utils
+
+        if app_settings.enable_registration_form_prefill:
+            return [utils.get_mapped_attributes(request)]
+        return []
+
+
+
 
 default_app_config = '%s.%s' % (__name__, 'AppConfig')
-- 
2.20.1

