Projet

Général

Profil

0002-idp.saml-rely-on-get_plugins-for-beeing-discovered-4.patch

Emmanuel Cazenave, 09 septembre 2020 15:20

Télécharger (1,84 ko)

Voir les différences:

Subject: [PATCH 2/6] idp.saml: rely on get_plugins for beeing discovered
 (#46474)

 src/authentic2/cors.py              |  2 +-
 src/authentic2/idp/saml/__init__.py | 13 ++++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)
src/authentic2/cors.py
58 58
    for whitelist_origin in app_settings.A2_CORS_WHITELIST:
59 59
        if whitelist_origin == origin:
60 60
            return True
61
    for plugin in itertools.chain(plugins.get_plugins(), apps.get_app_configs()):
61
    for plugin in plugins.get_plugins():
62 62
        if hasattr(plugin, 'check_origin'):
63 63
            if plugin.check_origin(request, origin):
64 64
                return True
src/authentic2/idp/saml/__init__.py
19 19
from django.apps import AppConfig
20 20

  
21 21

  
22
class SAML2IdPConfig(AppConfig):
23
    name = 'authentic2.idp.saml'
24
    label = 'authentic2_idp_saml'
22
class Plugin(object):
25 23

  
26 24
    def check_origin(self, request, origin):
27 25
        from authentic2.cors import make_origin
......
32 30
            if origin == provider_origin:
33 31
                return True
34 32

  
33

  
34
class SAML2IdPConfig(AppConfig):
35
    name = 'authentic2.idp.saml'
36
    label = 'authentic2_idp_saml'
37

  
38
    def get_a2_plugin(self):
39
        return Plugin()
40

  
41

  
35 42
default_app_config = 'authentic2.idp.saml.SAML2IdPConfig'
36 43

  
37 44

  
38
-