*: Adjust forms to only show respective types of Flows and PropertyMappings
This commit is contained in:
parent
fcf70a3cd4
commit
d4a5269bf1
|
@ -10,8 +10,10 @@ from passbook.providers.oauth.models import OAuth2Provider
|
|||
class OAuth2ProviderForm(forms.ModelForm):
|
||||
"""OAuth2 Provider form"""
|
||||
|
||||
authorization_flow = forms.ModelChoiceField(
|
||||
queryset=Flow.objects.filter(designation=FlowDesignation.AUTHORIZATION)
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["authorization_flow"].queryset = Flow.objects.filter(
|
||||
designation=FlowDesignation.AUTHORIZATION
|
||||
)
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""passbook OIDC IDP Forms"""
|
||||
|
||||
from django import forms
|
||||
from django.utils.translation import gettext as _
|
||||
from oauth2_provider.generators import generate_client_id, generate_client_secret
|
||||
from oidc_provider.models import Client
|
||||
|
||||
|
@ -12,7 +13,8 @@ class OIDCProviderForm(forms.ModelForm):
|
|||
"""OpenID Client form"""
|
||||
|
||||
authorization_flow = forms.ModelChoiceField(
|
||||
queryset=Flow.objects.filter(designation=FlowDesignation.AUTHORIZATION)
|
||||
queryset=Flow.objects.filter(designation=FlowDesignation.AUTHORIZATION),
|
||||
help_text=_("Flow used when authorizing this provider."),
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
|
|
@ -14,9 +14,12 @@ from passbook.providers.saml.models import SAMLPropertyMapping, SAMLProvider
|
|||
class SAMLProviderForm(forms.ModelForm):
|
||||
"""SAML Provider form"""
|
||||
|
||||
authorization_flow = forms.ModelChoiceField(
|
||||
queryset=Flow.objects.filter(designation=FlowDesignation.AUTHORIZATION)
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["authorization_flow"].queryset = Flow.objects.filter(
|
||||
designation=FlowDesignation.AUTHORIZATION
|
||||
)
|
||||
self.fields["property_mappings"].queryset = SAMLPropertyMapping.objects.all()
|
||||
|
||||
class Meta:
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ from django.contrib.admin.widgets import FilteredSelectMultiple
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from passbook.admin.fields import CodeMirrorWidget
|
||||
from passbook.admin.forms.source import SOURCE_FORM_FIELDS
|
||||
from passbook.core.expression import PropertyMappingEvaluator
|
||||
from passbook.sources.ldap.models import LDAPPropertyMapping, LDAPSource
|
||||
|
||||
|
@ -13,10 +12,19 @@ from passbook.sources.ldap.models import LDAPPropertyMapping, LDAPSource
|
|||
class LDAPSourceForm(forms.ModelForm):
|
||||
"""LDAPSource Form"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["property_mappings"].queryset = LDAPPropertyMapping.objects.all()
|
||||
|
||||
class Meta:
|
||||
|
||||
model = LDAPSource
|
||||
fields = SOURCE_FORM_FIELDS + [
|
||||
fields = [
|
||||
# we don't use all common fields, as we don't use flows for this
|
||||
"name",
|
||||
"slug",
|
||||
"enabled",
|
||||
# -- start of our custom fields
|
||||
"server_uri",
|
||||
"bind_cn",
|
||||
"bind_password",
|
||||
|
|
|
@ -11,15 +11,14 @@ from passbook.sources.oauth.types.manager import MANAGER
|
|||
class OAuthSourceForm(forms.ModelForm):
|
||||
"""OAuthSource Form"""
|
||||
|
||||
authentication_flow = forms.ModelChoiceField(
|
||||
queryset=Flow.objects.filter(designation=FlowDesignation.AUTHENTICATION)
|
||||
)
|
||||
enrollment_flow = forms.ModelChoiceField(
|
||||
queryset=Flow.objects.filter(designation=FlowDesignation.ENROLLMENT)
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["authentication_flow"].queryset = Flow.objects.filter(
|
||||
designation=FlowDesignation.AUTHENTICATION
|
||||
)
|
||||
self.fields["enrollment_flow"].queryset = Flow.objects.filter(
|
||||
designation=FlowDesignation.ENROLLMENT
|
||||
)
|
||||
if hasattr(self.Meta, "overrides"):
|
||||
for overide_field, overide_value in getattr(self.Meta, "overrides").items():
|
||||
self.fields[overide_field].initial = overide_value
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
"""passbook SAML SP Forms"""
|
||||
|
||||
from django import forms
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from passbook.admin.forms.source import SOURCE_FORM_FIELDS
|
||||
from passbook.crypto.models import CertificateKeyPair
|
||||
|
@ -12,17 +11,17 @@ from passbook.sources.saml.models import SAMLSource
|
|||
class SAMLSourceForm(forms.ModelForm):
|
||||
"""SAML Provider form"""
|
||||
|
||||
authentication_flow = forms.ModelChoiceField(
|
||||
queryset=Flow.objects.filter(designation=FlowDesignation.AUTHENTICATION)
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.fields["authentication_flow"].queryset = Flow.objects.filter(
|
||||
designation=FlowDesignation.AUTHENTICATION
|
||||
)
|
||||
enrollment_flow = forms.ModelChoiceField(
|
||||
queryset=Flow.objects.filter(designation=FlowDesignation.ENROLLMENT)
|
||||
self.fields["enrollment_flow"].queryset = Flow.objects.filter(
|
||||
designation=FlowDesignation.ENROLLMENT
|
||||
)
|
||||
signing_kp = forms.ModelChoiceField(
|
||||
queryset=CertificateKeyPair.objects.filter(
|
||||
self.fields["signing_kp"].queryset = CertificateKeyPair.objects.filter(
|
||||
certificate_data__isnull=False, key_data__isnull=False,
|
||||
),
|
||||
help_text=_("Certificate used to sign Requests."),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
|
|
Reference in a new issue