Projet

Général

Profil

0001-remove-authentic2_auth_cas-from-plugin-system-44329.patch

Emmanuel Cazenave, 23 juin 2020 11:41

Télécharger (5,52 ko)

Voir les différences:

Subject: [PATCH] remove authentic2_auth_cas from plugin system (#44329)

 setup.py                           |  1 -
 src/authentic2/settings.py         |  1 +
 src/authentic2/urls.py             | 10 ++++++++
 src/authentic2_idp_cas/__init__.py | 34 +-------------------------
 src/authentic2_idp_cas/apps.py     | 38 ++++++++++++++++++++++++++++++
 5 files changed, 50 insertions(+), 34 deletions(-)
 create mode 100644 src/authentic2_idp_cas/apps.py
setup.py
169 169
      },
170 170
      entry_points={
171 171
          'authentic2.plugin': [
172
              'authentic2-idp-cas = authentic2_idp_cas:Plugin',
173 172
              'authentic2-idp-oidc = authentic2_idp_oidc:Plugin',
174 173
              'authentic2-provisionning-ldap = authentic2_provisionning_ldap:Plugin',
175 174
              'authentic2-auth-fc = authentic2_auth_fc:Plugin',
src/authentic2/settings.py
131 131
    'mellon',
132 132
    'authentic2_auth_saml',
133 133
    'authentic2_auth_oidc',
134
    'authentic2_idp_cas',
134 135
    'authentic2.nonce',
135 136
    'authentic2.saml',
136 137
    'authentic2.idp',
src/authentic2/urls.py
27 27
from authentic2.decorators import setting_enabled, required, lasso_required
28 28
import authentic2_auth_oidc.urls
29 29
import authentic2_auth_saml.urls
30
import authentic2_idp_cas.app_settings
30 31
import authentic2.idp.saml.app_settings
31 32

  
32 33

  
......
157 158
    ),
158 159
    [url(r'^idp/saml2/', include('authentic2.idp.saml.urls'))]
159 160
)
161

  
162
authentic2_idp_cas_urls = required(
163
    (
164
        setting_enabled('ENABLE', settings=authentic2_idp_cas.app_settings),
165
    ),
166
    [url(r'^idp/cas/', include('authentic2_idp_cas.urls'))]
167
)
168

  
160 169
urlpatterns = (
170
    authentic2_idp_cas_urls +
161 171
    authentic2_auth_oidc.urls.urlpatterns +
162 172
    authentic2_auth_saml.urls.urlpatterns +
163 173
    authentic2_idp_saml_urls +
src/authentic2_idp_cas/__init__.py
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
from django.template.loader import render_to_string
18

  
19
from .constants import SESSION_CAS_LOGOUTS
20

  
21

  
22
class Plugin(object):
23
    def get_before_urls(self):
24
        from . import app_settings
25
        from django.conf.urls import include, url
26
        from authentic2.decorators import setting_enabled, required
27

  
28
        return required(
29
            (
30
                setting_enabled('ENABLE', settings=app_settings),
31
            ),
32
            [url(r'^idp/cas/', include(__name__ + '.urls'))])
33

  
34
    def get_apps(self):
35
        return [__name__]
36

  
37
    def logout_list(self, request):
38
        fragments = []
39
        cas_logouts = request.session.get(SESSION_CAS_LOGOUTS, [])
40
        for name, url, use_iframe, use_iframe_timeout in cas_logouts:
41
            ctx = {
42
                'needs_iframe': use_iframe,
43
                'name': name,
44
                'url': url,
45
                'iframe_timeout': use_iframe_timeout,
46
            }
47
            content = render_to_string('authentic2_idp_cas/logout_fragment.html', ctx)
48
            fragments.append(content)
49
        return fragments
17
default_app_config = 'authentic2_idp_cas.apps.AppConfig'
src/authentic2_idp_cas/apps.py
1
# authentic2 - versatile identity manager
2
# Copyright (C) 2010-2020 Entr'ouvert
3
#
4
# This program is free software: you can redistribute it and/or modify it
5
# under the terms of the GNU Affero General Public License as published
6
# by the Free Software Foundation, either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU Affero General Public License for more details.
13
#
14
# You should have received a copy of the GNU Affero General Public License
15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16

  
17
import django.apps
18
from django.template.loader import render_to_string
19

  
20
from .constants import SESSION_CAS_LOGOUTS
21

  
22

  
23
class AppConfig(django.apps.AppConfig):
24
    name = 'authentic2_idp_cas'
25

  
26
    def logout_list(self, request):
27
        fragments = []
28
        cas_logouts = request.session.get(SESSION_CAS_LOGOUTS, [])
29
        for name, url, use_iframe, use_iframe_timeout in cas_logouts:
30
            ctx = {
31
                'needs_iframe': use_iframe,
32
                'name': name,
33
                'url': url,
34
                'iframe_timeout': use_iframe_timeout,
35
            }
36
            content = render_to_string('authentic2_idp_cas/logout_fragment.html', ctx)
37
            fragments.append(content)
38
        return fragments
0
-