2019-11-07 16:02:56 +00:00
|
|
|
"""passbook SAML SP Forms"""
|
|
|
|
|
|
|
|
from django import forms
|
2019-11-07 16:28:59 +00:00
|
|
|
from django.contrib.admin.widgets import FilteredSelectMultiple
|
|
|
|
from django.utils.translation import gettext as _
|
2019-11-07 16:02:56 +00:00
|
|
|
|
2019-11-07 16:28:59 +00:00
|
|
|
from passbook.admin.forms.source import SOURCE_FORM_FIELDS
|
2019-11-07 16:02:56 +00:00
|
|
|
from passbook.providers.saml.utils import CertificateBuilder
|
|
|
|
from passbook.sources.saml.models import SAMLSource
|
|
|
|
|
|
|
|
|
|
|
|
class SAMLSourceForm(forms.ModelForm):
|
|
|
|
"""SAML Provider form"""
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
builder = CertificateBuilder()
|
|
|
|
builder.build()
|
|
|
|
self.fields['signing_cert'].initial = builder.certificate
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
model = SAMLSource
|
2019-11-07 16:28:59 +00:00
|
|
|
fields = SOURCE_FORM_FIELDS + ['entity_id', 'idp_url',
|
|
|
|
'idp_logout_url', 'auto_logout', 'signing_cert']
|
2019-11-07 16:02:56 +00:00
|
|
|
labels = {
|
|
|
|
'entity_id': 'Entity ID',
|
|
|
|
'idp_url': 'IDP URL',
|
|
|
|
'idp_logout_url': 'IDP Logout URL',
|
|
|
|
}
|
|
|
|
widgets = {
|
|
|
|
'name': forms.TextInput(),
|
2019-11-07 16:28:59 +00:00
|
|
|
'policies': FilteredSelectMultiple(_('policies'), False),
|
2019-11-07 16:02:56 +00:00
|
|
|
'entity_id': forms.TextInput(),
|
|
|
|
'idp_url': forms.TextInput(),
|
|
|
|
'idp_logout_url': forms.TextInput(),
|
|
|
|
}
|