authentik.flows.api.bindings
Flow Binding API Views
1"""Flow Binding API Views""" 2 3from typing import Any 4 5from rest_framework.exceptions import ValidationError 6from rest_framework.viewsets import ModelViewSet 7 8from authentik.core.api.used_by import UsedByMixin 9from authentik.core.api.utils import ModelSerializer 10from authentik.flows.api.stages import StageSerializer 11from authentik.flows.models import FlowStageBinding 12 13 14class FlowStageBindingSerializer(ModelSerializer): 15 """FlowStageBinding Serializer""" 16 17 stage_obj = StageSerializer(read_only=True, source="stage") 18 19 def validate(self, attrs: dict[str, Any]) -> dict[str, Any]: 20 evaluate_on_plan = attrs.get("evaluate_on_plan", False) 21 re_evaluate_policies = attrs.get("re_evaluate_policies", True) 22 if not evaluate_on_plan and not re_evaluate_policies: 23 raise ValidationError("Either evaluation on plan or evaluation on run must be enabled") 24 return super().validate(attrs) 25 26 class Meta: 27 model = FlowStageBinding 28 fields = [ 29 "pk", 30 "policybindingmodel_ptr_id", 31 "target", 32 "stage", 33 "stage_obj", 34 "evaluate_on_plan", 35 "re_evaluate_policies", 36 "order", 37 "policy_engine_mode", 38 "invalid_response_action", 39 ] 40 41 42class FlowStageBindingViewSet(UsedByMixin, ModelViewSet): 43 """FlowStageBinding Viewset""" 44 45 queryset = FlowStageBinding.objects.all() 46 serializer_class = FlowStageBindingSerializer 47 filterset_fields = "__all__" 48 search_fields = ["stage__name"] 49 ordering = ["order", "pk"] 50 ordering_fields = ["order", "stage__name", "target__uuid", "pk"]
15class FlowStageBindingSerializer(ModelSerializer): 16 """FlowStageBinding Serializer""" 17 18 stage_obj = StageSerializer(read_only=True, source="stage") 19 20 def validate(self, attrs: dict[str, Any]) -> dict[str, Any]: 21 evaluate_on_plan = attrs.get("evaluate_on_plan", False) 22 re_evaluate_policies = attrs.get("re_evaluate_policies", True) 23 if not evaluate_on_plan and not re_evaluate_policies: 24 raise ValidationError("Either evaluation on plan or evaluation on run must be enabled") 25 return super().validate(attrs) 26 27 class Meta: 28 model = FlowStageBinding 29 fields = [ 30 "pk", 31 "policybindingmodel_ptr_id", 32 "target", 33 "stage", 34 "stage_obj", 35 "evaluate_on_plan", 36 "re_evaluate_policies", 37 "order", 38 "policy_engine_mode", 39 "invalid_response_action", 40 ]
FlowStageBinding Serializer
def
validate(self, attrs: dict[str, typing.Any]) -> dict[str, typing.Any]:
20 def validate(self, attrs: dict[str, Any]) -> dict[str, Any]: 21 evaluate_on_plan = attrs.get("evaluate_on_plan", False) 22 re_evaluate_policies = attrs.get("re_evaluate_policies", True) 23 if not evaluate_on_plan and not re_evaluate_policies: 24 raise ValidationError("Either evaluation on plan or evaluation on run must be enabled") 25 return super().validate(attrs)
Inherited Members
class
FlowStageBindingSerializer.Meta:
27 class Meta: 28 model = FlowStageBinding 29 fields = [ 30 "pk", 31 "policybindingmodel_ptr_id", 32 "target", 33 "stage", 34 "stage_obj", 35 "evaluate_on_plan", 36 "re_evaluate_policies", 37 "order", 38 "policy_engine_mode", 39 "invalid_response_action", 40 ]
model =
<class 'authentik.flows.models.FlowStageBinding'>
class
FlowStageBindingViewSet(authentik.core.api.used_by.UsedByMixin, rest_framework.viewsets.ModelViewSet):
43class FlowStageBindingViewSet(UsedByMixin, ModelViewSet): 44 """FlowStageBinding Viewset""" 45 46 queryset = FlowStageBinding.objects.all() 47 serializer_class = FlowStageBindingSerializer 48 filterset_fields = "__all__" 49 search_fields = ["stage__name"] 50 ordering = ["order", "pk"] 51 ordering_fields = ["order", "stage__name", "target__uuid", "pk"]
FlowStageBinding Viewset
serializer_class =
<class 'FlowStageBindingSerializer'>