a4dc6d13b5
* events: rename audit to events * policies/expression: log expression exceptions as event * policies/expression: add ExpressionPolicy Model to event when possible * lib/expressions: ensure syntax errors are logged too * lib: fix lint error * policies: add execution_logging field * core: add property mapping tests * policies/expression: add full test * policies/expression: fix attribute name * policies: add execution_logging * web: fix imports * root: update swagger * policies: use dataclass instead of dict for types * events: add support for dataclass as event param * events: add special keys which are never cleaned * policies: add tests for process, don't clean full cache * admin: create event when new version is seen * events: move utils to separate file * admin: add tests for admin tasks * events: add .set_user method to ensure users have correct attributes set * core: add test for property_mapping errors with user and request
32 lines
935 B
Python
32 lines
935 B
Python
"""General fields"""
|
|
|
|
from django import forms
|
|
|
|
from authentik.lib.widgets import GroupedModelChoiceField
|
|
from authentik.policies.models import Policy, PolicyBinding, PolicyBindingModel
|
|
|
|
GENERAL_FIELDS = ["name", "execution_logging"]
|
|
GENERAL_SERIALIZER_FIELDS = ["pk", "name"]
|
|
|
|
|
|
class PolicyBindingForm(forms.ModelForm):
|
|
"""Form to edit Policy to PolicyBindingModel Binding"""
|
|
|
|
target = GroupedModelChoiceField(
|
|
queryset=PolicyBindingModel.objects.all().select_subclasses(),
|
|
to_field_name="pbm_uuid",
|
|
)
|
|
policy = GroupedModelChoiceField(
|
|
queryset=Policy.objects.all().select_subclasses(),
|
|
)
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
if "target" in self.initial:
|
|
self.fields["target"].widget = forms.HiddenInput()
|
|
|
|
class Meta:
|
|
|
|
model = PolicyBinding
|
|
fields = ["enabled", "policy", "target", "order", "timeout"]
|