From 1b0c013d8efbce4db2b7589b6d9697bbb7580d0b Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 11 Jul 2020 13:28:03 +0200 Subject: [PATCH] providers/saml: remove processor_path field --- passbook/providers/saml/api.py | 1 - passbook/providers/saml/apps.py | 18 ++---------------- passbook/providers/saml/forms.py | 10 +--------- passbook/providers/saml/models.py | 26 -------------------------- swagger.yaml | 6 ------ 5 files changed, 3 insertions(+), 58 deletions(-) diff --git a/passbook/providers/saml/api.py b/passbook/providers/saml/api.py index 0f1b950f3..f2023eae7 100644 --- a/passbook/providers/saml/api.py +++ b/passbook/providers/saml/api.py @@ -14,7 +14,6 @@ class SAMLProviderSerializer(ModelSerializer): fields = [ "pk", "name", - "processor_path", "acs_url", "audience", "issuer", diff --git a/passbook/providers/saml/apps.py b/passbook/providers/saml/apps.py index 055d748d7..dcefbe59f 100644 --- a/passbook/providers/saml/apps.py +++ b/passbook/providers/saml/apps.py @@ -1,26 +1,12 @@ -"""passbook mod saml_idp app config""" -from importlib import import_module +"""passbook SAML IdP app config""" from django.apps import AppConfig -from django.conf import settings -from structlog import get_logger - -LOGGER = get_logger() class PassbookProviderSAMLConfig(AppConfig): - """passbook saml_idp app config""" + """passbook SAML IdP app config""" name = "passbook.providers.saml" label = "passbook_providers_saml" verbose_name = "passbook Providers.SAML" mountpoint = "application/saml/" - - def ready(self): - """Load source_types from config file""" - for source_type in settings.PASSBOOK_PROVIDERS_SAML_PROCESSORS: - try: - import_module(source_type) - LOGGER.info("Loaded SAML Processor", processor_class=source_type) - except ImportError as exc: - LOGGER.debug(exc) diff --git a/passbook/providers/saml/forms.py b/passbook/providers/saml/forms.py index a5b4d17c7..c49979af9 100644 --- a/passbook/providers/saml/forms.py +++ b/passbook/providers/saml/forms.py @@ -8,11 +8,7 @@ from django.utils.translation import gettext as _ from passbook.admin.fields import CodeMirrorWidget from passbook.core.expression import PropertyMappingEvaluator from passbook.flows.models import Flow, FlowDesignation -from passbook.providers.saml.models import ( - SAMLPropertyMapping, - SAMLProvider, - get_provider_choices, -) +from passbook.providers.saml.models import SAMLPropertyMapping, SAMLProvider class SAMLProviderForm(forms.ModelForm): @@ -21,9 +17,6 @@ class SAMLProviderForm(forms.ModelForm): authorization_flow = forms.ModelChoiceField( queryset=Flow.objects.filter(designation=FlowDesignation.AUTHORIZATION) ) - processor_path = forms.ChoiceField( - choices=get_provider_choices(), label="Processor" - ) class Meta: @@ -31,7 +24,6 @@ class SAMLProviderForm(forms.ModelForm): fields = [ "name", "authorization_flow", - "processor_path", "acs_url", "audience", "issuer", diff --git a/passbook/providers/saml/models.py b/passbook/providers/saml/models.py index 59dfe392a..56b6a8c74 100644 --- a/passbook/providers/saml/models.py +++ b/passbook/providers/saml/models.py @@ -9,9 +9,7 @@ from structlog import get_logger from passbook.core.models import PropertyMapping, Provider from passbook.crypto.models import CertificateKeyPair -from passbook.lib.utils.reflection import class_to_path, path_to_class from passbook.lib.utils.template import render_to_string -from passbook.providers.saml.processors.base import Processor from passbook.providers.saml.utils.time import timedelta_string_validator LOGGER = get_logger() @@ -28,7 +26,6 @@ class SAMLProvider(Provider): """SAML 2.0 Endpoint for applications which support SAML.""" name = models.TextField() - processor_path = models.CharField(max_length=255, choices=[]) acs_url = models.URLField(verbose_name=_("ACS URL")) audience = models.TextField(default="") @@ -105,22 +102,6 @@ class SAMLProvider(Provider): ) form = "passbook.providers.saml.forms.SAMLProviderForm" - _processor = None - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self._meta.get_field("processor_path").choices = get_provider_choices() - - @property - def processor(self) -> Optional[Processor]: - """Return selected processor as instance""" - if not self._processor: - try: - self._processor = path_to_class(self.processor_path)(self) - except ImportError as exc: - LOGGER.warning(exc) - self._processor = None - return self._processor def __str__(self): return self.name @@ -171,10 +152,3 @@ class SAMLPropertyMapping(PropertyMapping): verbose_name = _("SAML Property Mapping") verbose_name_plural = _("SAML Property Mappings") - - -def get_provider_choices(): - """Return tuple of class_path, class name of all providers.""" - return [ - (class_to_path(x), x.__name__) for x in getattr(Processor, "__subclasses__")() - ] diff --git a/swagger.yaml b/swagger.yaml index b224c1175..2539f357c 100755 --- a/swagger.yaml +++ b/swagger.yaml @@ -6154,7 +6154,6 @@ definitions: SAMLProvider: required: - name - - processor_path - acs_url - issuer type: object @@ -6167,11 +6166,6 @@ definitions: title: Name type: string minLength: 1 - processor_path: - title: Processor path - type: string - maxLength: 255 - minLength: 1 acs_url: title: ACS URL type: string