saml_idp: Add Certificate, Key and other settings to DB
This commit is contained in:
parent
dae5fc6265
commit
9cccc0a757
|
@ -188,7 +188,7 @@ class Processor:
|
|||
'acs_url': self._request_params['ACS_URL'],
|
||||
'saml_response': self._saml_response,
|
||||
'relay_state': self._relay_state,
|
||||
'autosubmit': CONFIG.y('saml_idp.autosubmit', False),
|
||||
'autosubmit': False, # TODO: use autosubmit from application
|
||||
}
|
||||
|
||||
def _parse_request(self):
|
||||
|
|
|
@ -2,13 +2,24 @@
|
|||
|
||||
from django import forms
|
||||
|
||||
from passbook.saml_idp.models import SAMLProvider
|
||||
from passbook.saml_idp.models import SAMLProvider, get_provider_choices
|
||||
|
||||
|
||||
class SAMLProviderForm(forms.ModelForm):
|
||||
"""SAML Provider form"""
|
||||
|
||||
processor_path = forms.ChoiceField(choices=get_provider_choices(), label='Processor')
|
||||
|
||||
class Meta:
|
||||
|
||||
model = SAMLProvider
|
||||
fields = ['name', 'acs_url', 'processor_path', ]
|
||||
fields = ['name', 'acs_url', 'processor_path', 'issuer',
|
||||
'assertion_valid_for', 'signing', 'signing_cert', 'signing_key', ]
|
||||
labels = {
|
||||
'acs_url': 'ACS URL',
|
||||
'signing_cert': 'Singing Certificate',
|
||||
}
|
||||
widgets = {
|
||||
'name': forms.TextInput(),
|
||||
'issuer': forms.TextInput(),
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
# Generated by Django 2.1.4 on 2018-12-09 22:02
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('passbook_saml_idp', '0003_auto_20181126_1514'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='samlprovider',
|
||||
name='assertion_valid_for',
|
||||
field=models.IntegerField(default=86400),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='samlprovider',
|
||||
name='issuer',
|
||||
field=models.TextField(default=''),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='samlprovider',
|
||||
name='signing',
|
||||
field=models.BooleanField(default=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='samlprovider',
|
||||
name='signing_cert',
|
||||
field=models.TextField(default=''),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='samlprovider',
|
||||
name='signing_key',
|
||||
field=models.TextField(default=''),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
|
@ -14,13 +14,17 @@ class SAMLProvider(Provider):
|
|||
name = models.TextField()
|
||||
acs_url = models.URLField()
|
||||
processor_path = models.CharField(max_length=255, choices=[])
|
||||
issuer = models.TextField()
|
||||
assertion_valid_for = models.IntegerField(default=86400)
|
||||
signing = models.BooleanField(default=True)
|
||||
signing_cert = models.TextField()
|
||||
signing_key = models.TextField()
|
||||
|
||||
form = 'passbook.saml_idp.forms.SAMLProviderForm'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
processors = [(class_to_path(x), x.__name__) for x in Processor.__subclasses__()]
|
||||
self._meta.get_field('processor_path').choices = processors
|
||||
self._meta.get_field('processor_path').choices = get_provider_choices()
|
||||
|
||||
def __str__(self):
|
||||
return "SAMLProvider %s (processor=%s)" % (self.name, self.processor_path)
|
||||
|
@ -29,3 +33,8 @@ class SAMLProvider(Provider):
|
|||
|
||||
verbose_name = _('SAML Provider')
|
||||
verbose_name_plural = _('SAML Providers')
|
||||
|
||||
|
||||
def get_provider_choices():
|
||||
"""Return tuple of class_path, class name of all providers."""
|
||||
return [(class_to_path(x), x.__name__) for x in Processor.__subclasses__()]
|
||||
|
|
Reference in New Issue