2019-03-20 21:42:47 +00:00
|
|
|
"""passbook Application Security Gateway Forms"""
|
|
|
|
|
|
|
|
from django import forms
|
|
|
|
from django.contrib.admin.widgets import FilteredSelectMultiple
|
|
|
|
from django.utils.translation import gettext as _
|
|
|
|
|
2019-03-21 15:21:51 +00:00
|
|
|
from passbook.app_gw.models import ApplicationGatewayProvider, RewriteRule
|
2019-03-20 21:42:47 +00:00
|
|
|
from passbook.lib.fields import DynamicArrayField
|
|
|
|
|
|
|
|
|
|
|
|
class ApplicationGatewayProviderForm(forms.ModelForm):
|
|
|
|
"""Security Gateway Provider form"""
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
model = ApplicationGatewayProvider
|
|
|
|
fields = ['server_name', 'upstream', 'enabled', 'authentication_header',
|
2019-03-21 15:21:51 +00:00
|
|
|
'default_content_type', 'upstream_ssl_verification', 'property_mappings']
|
2019-03-20 21:42:47 +00:00
|
|
|
widgets = {
|
|
|
|
'authentication_header': forms.TextInput(),
|
|
|
|
'default_content_type': forms.TextInput(),
|
|
|
|
'property_mappings': FilteredSelectMultiple(_('Property Mappings'), False)
|
|
|
|
}
|
|
|
|
field_classes = {
|
|
|
|
'server_name': DynamicArrayField,
|
|
|
|
'upstream': DynamicArrayField
|
|
|
|
}
|
|
|
|
labels = {
|
2019-03-21 15:21:51 +00:00
|
|
|
'upstream_ssl_verification': _('Verify upstream SSL Certificates?'),
|
|
|
|
'property_mappings': _('Rewrite Rules')
|
|
|
|
}
|
|
|
|
|
|
|
|
class RewriteRuleForm(forms.ModelForm):
|
|
|
|
"""Rewrite Rule Form"""
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
model = RewriteRule
|
|
|
|
fields = ['name', 'match', 'halt', 'replacement', 'redirect', 'conditions']
|
|
|
|
widgets = {
|
|
|
|
'name': forms.TextInput(),
|
|
|
|
'match': forms.TextInput(attrs={'data-is-monospace': True}),
|
|
|
|
'replacement': forms.TextInput(attrs={'data-is-monospace': True}),
|
|
|
|
'conditions': FilteredSelectMultiple(_('Conditions'), False)
|
2019-03-20 21:42:47 +00:00
|
|
|
}
|