providers/saml: remove processor_path field
This commit is contained in:
parent
92a09be8c0
commit
1b0c013d8e
|
@ -14,7 +14,6 @@ class SAMLProviderSerializer(ModelSerializer):
|
|||
fields = [
|
||||
"pk",
|
||||
"name",
|
||||
"processor_path",
|
||||
"acs_url",
|
||||
"audience",
|
||||
"issuer",
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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__")()
|
||||
]
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in New Issue