From b7e4ad72344d1b03cc5aa923fcc233ac344f554a Mon Sep 17 00:00:00 2001 From: Jens L Date: Fri, 24 Feb 2023 11:22:02 +0100 Subject: [PATCH] web/user: fix source connections not being filtered (#4778) Signed-off-by: Jens Langhammer --- authentik/core/api/sources.py | 1 + schema.yml | 4 ++++ web/src/user/user-settings/sources/SourceSettings.ts | 8 +++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/authentik/core/api/sources.py b/authentik/core/api/sources.py index ffbdce1d1..7c3d5c435 100644 --- a/authentik/core/api/sources.py +++ b/authentik/core/api/sources.py @@ -206,5 +206,6 @@ class UserSourceConnectionViewSet( queryset = UserSourceConnection.objects.all() serializer_class = UserSourceConnectionSerializer permission_classes = [OwnerSuperuserPermissions] + filterset_fields = ["user"] filter_backends = [OwnerFilter, DjangoFilterBackend, OrderingFilter, SearchFilter] ordering = ["pk"] diff --git a/schema.yml b/schema.yml index 7709b63b0..c7c418bdb 100644 --- a/schema.yml +++ b/schema.yml @@ -17568,6 +17568,10 @@ paths: description: A search term. schema: type: string + - in: query + name: user + schema: + type: integer tags: - sources security: diff --git a/web/src/user/user-settings/sources/SourceSettings.ts b/web/src/user/user-settings/sources/SourceSettings.ts index 702d4f719..3463b3b94 100644 --- a/web/src/user/user-settings/sources/SourceSettings.ts +++ b/web/src/user/user-settings/sources/SourceSettings.ts @@ -1,6 +1,7 @@ import { renderSourceIcon } from "@goauthentik/admin/sources/SourceViewPage"; import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { EVENT_REFRESH } from "@goauthentik/common/constants"; +import { me } from "@goauthentik/common/users"; import { AKElement } from "@goauthentik/elements/Base"; import "@goauthentik/elements/EmptyState"; import "@goauthentik/user/user-settings/sources/SourceSettingsOAuth"; @@ -58,10 +59,11 @@ export class UserSourceSettingsPage extends AKElement { }); } - firstUpdated(): void { + async firstUpdated(): Promise { + const user = await me(); this.sourceSettings = new SourcesApi(DEFAULT_CONFIG).sourcesAllUserSettingsList(); - new SourcesApi(DEFAULT_CONFIG).sourcesUserConnectionsAllList().then((connections) => { - this.connections = connections; + this.connections = await new SourcesApi(DEFAULT_CONFIG).sourcesUserConnectionsAllList({ + user: user.user.pk, }); }