2021-01-11 17:43:59 +00:00
|
|
|
"""Event Matcher Policy API"""
|
|
|
|
from rest_framework.viewsets import ModelViewSet
|
|
|
|
|
2021-06-10 09:58:12 +00:00
|
|
|
from authentik.core.api.used_by import UsedByMixin
|
2021-03-29 21:32:42 +00:00
|
|
|
from authentik.policies.api.policies import PolicySerializer
|
2021-01-11 17:43:59 +00:00
|
|
|
from authentik.policies.event_matcher.models import EventMatcherPolicy
|
|
|
|
|
|
|
|
|
2021-02-11 18:48:19 +00:00
|
|
|
class EventMatcherPolicySerializer(PolicySerializer):
|
2021-01-11 17:43:59 +00:00
|
|
|
"""Event Matcher Policy Serializer"""
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = EventMatcherPolicy
|
2021-02-11 18:48:19 +00:00
|
|
|
fields = PolicySerializer.Meta.fields + [
|
2021-01-11 17:43:59 +00:00
|
|
|
"action",
|
|
|
|
"client_ip",
|
|
|
|
"app",
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2021-06-10 09:58:12 +00:00
|
|
|
class EventMatcherPolicyViewSet(UsedByMixin, ModelViewSet):
|
2021-01-11 17:43:59 +00:00
|
|
|
"""Event Matcher Policy Viewset"""
|
|
|
|
|
|
|
|
queryset = EventMatcherPolicy.objects.all()
|
|
|
|
serializer_class = EventMatcherPolicySerializer
|
2021-08-07 14:12:38 +00:00
|
|
|
filterset_fields = "__all__"
|
|
|
|
ordering = ["name"]
|
2022-05-24 20:01:18 +00:00
|
|
|
search_fields = ["name"]
|