policies: fix policybinding API returning wrong policy objects

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-04-06 17:24:32 +02:00
parent b09943e106
commit a31fc8319d
2 changed files with 3 additions and 2 deletions

View file

@ -15,6 +15,7 @@ authentik API Browser
spec-url="{{ path }}" spec-url="{{ path }}"
heading-text="authentik" heading-text="authentik"
theme="dark" theme="dark"
render-style="view"
primary-color="#fd4b2d" primary-color="#fd4b2d"
allow-spec-url-load="false" allow-spec-url-load="false"
allow-spec-file-load="false"> allow-spec-file-load="false">

View file

@ -102,8 +102,8 @@ class PolicyBindingViewSet(ModelViewSet):
"""PolicyBinding Viewset""" """PolicyBinding Viewset"""
queryset = PolicyBinding.objects.all().select_related( queryset = PolicyBinding.objects.all().select_related(
"policy", "target", "group", "user" "target", "group", "user"
) ).prefetch_related("policy") # prefetching policy so we resolve the subclass
serializer_class = PolicyBindingSerializer serializer_class = PolicyBindingSerializer
filterset_fields = ["policy", "target", "enabled", "order", "timeout"] filterset_fields = ["policy", "target", "enabled", "order", "timeout"]
search_fields = ["policy__name"] search_fields = ["policy__name"]