2019-02-16 09:24:31 +00:00
|
|
|
"""passbook Policy forms"""
|
2018-11-26 21:08:48 +00:00
|
|
|
|
|
|
|
from django import forms
|
2018-12-14 14:18:02 +00:00
|
|
|
from django.utils.translation import gettext as _
|
2018-11-26 21:08:48 +00:00
|
|
|
|
2019-02-26 14:41:11 +00:00
|
|
|
from passbook.core.models import (DebugPolicy, FieldMatcherPolicy,
|
2019-03-10 18:32:18 +00:00
|
|
|
GroupMembershipPolicy, PasswordPolicy,
|
2019-04-29 21:19:37 +00:00
|
|
|
SSOLoginPolicy, WebhookPolicy)
|
2018-11-26 21:08:48 +00:00
|
|
|
|
2019-03-21 13:48:51 +00:00
|
|
|
GENERAL_FIELDS = ['name', 'action', 'negate', 'order', 'timeout']
|
2018-11-26 21:08:48 +00:00
|
|
|
|
2019-02-16 09:24:31 +00:00
|
|
|
class FieldMatcherPolicyForm(forms.ModelForm):
|
|
|
|
"""FieldMatcherPolicy Form"""
|
2018-11-26 21:08:48 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
2019-02-16 09:24:31 +00:00
|
|
|
model = FieldMatcherPolicy
|
2018-12-09 20:06:21 +00:00
|
|
|
fields = GENERAL_FIELDS + ['user_field', 'match_action', 'value', ]
|
2018-11-26 21:08:48 +00:00
|
|
|
widgets = {
|
|
|
|
'name': forms.TextInput(),
|
|
|
|
'value': forms.TextInput(),
|
|
|
|
}
|
2018-11-27 15:23:04 +00:00
|
|
|
|
|
|
|
|
2019-02-16 09:24:31 +00:00
|
|
|
class WebhookPolicyForm(forms.ModelForm):
|
|
|
|
"""WebhookPolicyForm Form"""
|
2018-11-27 15:23:04 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
2019-02-16 09:24:31 +00:00
|
|
|
model = WebhookPolicy
|
2018-12-09 20:06:21 +00:00
|
|
|
fields = GENERAL_FIELDS + ['url', 'method', 'json_body', 'json_headers',
|
|
|
|
'result_jsonpath', 'result_json_value', ]
|
2018-11-27 15:23:04 +00:00
|
|
|
widgets = {
|
2018-12-09 20:06:21 +00:00
|
|
|
'name': forms.TextInput(),
|
2018-11-27 15:23:04 +00:00
|
|
|
'json_body': forms.TextInput(),
|
|
|
|
'json_headers': forms.TextInput(),
|
|
|
|
'result_jsonpath': forms.TextInput(),
|
|
|
|
'result_json_value': forms.TextInput(),
|
|
|
|
}
|
2018-12-09 20:06:21 +00:00
|
|
|
|
|
|
|
|
2019-02-16 09:24:31 +00:00
|
|
|
class DebugPolicyForm(forms.ModelForm):
|
|
|
|
"""DebugPolicyForm Form"""
|
2018-12-09 20:06:21 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
2019-02-16 09:24:31 +00:00
|
|
|
model = DebugPolicy
|
2018-12-09 20:06:21 +00:00
|
|
|
fields = GENERAL_FIELDS + ['result', 'wait_min', 'wait_max']
|
|
|
|
widgets = {
|
|
|
|
'name': forms.TextInput(),
|
|
|
|
}
|
2018-12-14 14:18:02 +00:00
|
|
|
labels = {
|
|
|
|
'result': _('Allow user')
|
|
|
|
}
|
2019-02-26 14:41:11 +00:00
|
|
|
|
|
|
|
|
2019-03-10 18:32:18 +00:00
|
|
|
class GroupMembershipPolicyForm(forms.ModelForm):
|
|
|
|
"""GroupMembershipPolicy Form"""
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
model = GroupMembershipPolicy
|
|
|
|
fields = GENERAL_FIELDS + ['group', ]
|
|
|
|
widgets = {
|
|
|
|
'name': forms.TextInput(),
|
2019-04-29 21:16:04 +00:00
|
|
|
'order': forms.NumberInput(),
|
2019-03-10 18:32:18 +00:00
|
|
|
}
|
|
|
|
|
2019-04-29 21:19:37 +00:00
|
|
|
class SSOLoginPolicyForm(forms.ModelForm):
|
|
|
|
"""Edit SSOLoginPolicy instances"""
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
model = SSOLoginPolicy
|
|
|
|
fields = GENERAL_FIELDS
|
|
|
|
widgets = {
|
|
|
|
'name': forms.TextInput(),
|
|
|
|
'order': forms.NumberInput(),
|
|
|
|
}
|
|
|
|
|
2019-02-26 14:41:11 +00:00
|
|
|
class PasswordPolicyForm(forms.ModelForm):
|
|
|
|
"""PasswordPolicy Form"""
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
model = PasswordPolicy
|
|
|
|
fields = GENERAL_FIELDS + ['amount_uppercase', 'amount_lowercase',
|
|
|
|
'amount_symbols', 'length_min', 'symbol_charset',
|
|
|
|
'error_message']
|
|
|
|
widgets = {
|
|
|
|
'name': forms.TextInput(),
|
|
|
|
'symbol_charset': forms.TextInput(),
|
|
|
|
'error_message': forms.TextInput(),
|
|
|
|
}
|
|
|
|
labels = {
|
|
|
|
'amount_uppercase': _('Minimum amount of Uppercase Characters'),
|
|
|
|
'amount_lowercase': _('Minimum amount of Lowercase Characters'),
|
|
|
|
'amount_symbols': _('Minimum amount of Symbols Characters'),
|
|
|
|
'length_min': _('Minimum Length'),
|
|
|
|
}
|