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 }}"
heading-text="authentik"
theme="dark"
render-style="view"
primary-color="#fd4b2d"
allow-spec-url-load="false"
allow-spec-file-load="false">

View File

@ -102,8 +102,8 @@ class PolicyBindingViewSet(ModelViewSet):
"""PolicyBinding Viewset"""
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
filterset_fields = ["policy", "target", "enabled", "order", "timeout"]
search_fields = ["policy__name"]