From 4766d6ff3da379e20d2dc5aff8bd2271ffbb9e13 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 10 Jun 2021 13:52:50 +0200 Subject: [PATCH] flows: add export URL to API Signed-off-by: Jens Langhammer --- authentik/flows/api/flows.py | 7 +++++++ schema.yml | 4 ++++ web/src/pages/flows/FlowListPage.ts | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/authentik/flows/api/flows.py b/authentik/flows/api/flows.py index 97fda014c..48b0fd23e 100644 --- a/authentik/flows/api/flows.py +++ b/authentik/flows/api/flows.py @@ -45,10 +45,16 @@ class FlowSerializer(ModelSerializer): background = ReadOnlyField(source="background_url") + export_url = SerializerMethodField() + def get_cache_count(self, flow: Flow) -> int: """Get count of cached flows""" return len(cache.keys(f"{cache_key(flow)}*")) + def get_export_url(self, flow: Flow) -> str: + """Get export URL for flow""" + return reverse("authentik_api:flow-export", kwargs={"slug": flow.slug}) + class Meta: model = Flow @@ -65,6 +71,7 @@ class FlowSerializer(ModelSerializer): "cache_count", "policy_engine_mode", "compatibility_mode", + "export_url", ] extra_kwargs = { "background": {"read_only": True}, diff --git a/schema.yml b/schema.yml index 47db1e3d5..8ab430338 100644 --- a/schema.yml +++ b/schema.yml @@ -19372,10 +19372,14 @@ components: type: boolean description: Enable compatibility mode, increases compatibility with password managers on mobile devices. + export_url: + type: string + readOnly: true required: - background - cache_count - designation + - export_url - name - pk - policies diff --git a/web/src/pages/flows/FlowListPage.ts b/web/src/pages/flows/FlowListPage.ts index 2994c1a61..037da0db2 100644 --- a/web/src/pages/flows/FlowListPage.ts +++ b/web/src/pages/flows/FlowListPage.ts @@ -103,7 +103,7 @@ export class FlowListPage extends TablePage { }}> ${t`Execute`} - + ${t`Export`} `, ];