Skip to content

Commit 1ce3dfd

Browse files
authored
sources: allow uuid or slug to be used for retrieving a source (#12780)
Signed-off-by: Jens Langhammer <[email protected]>
1 parent ce7e539 commit 1ce3dfd

File tree

8 files changed

+40
-3
lines changed

8 files changed

+40
-3
lines changed

authentik/sources/kerberos/api/source.py

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class KerberosSourceViewSet(UsedByMixin, ModelViewSet):
6666
serializer_class = KerberosSourceSerializer
6767
lookup_field = "slug"
6868
filterset_fields = [
69+
"pbm_uuid",
6970
"name",
7071
"slug",
7172
"enabled",

authentik/sources/ldap/api.py

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class LDAPSourceViewSet(UsedByMixin, ModelViewSet):
110110
serializer_class = LDAPSourceSerializer
111111
lookup_field = "slug"
112112
filterset_fields = [
113+
"pbm_uuid",
113114
"name",
114115
"slug",
115116
"enabled",

authentik/sources/oauth/api/source.py

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def filter_has_jwks(self, queryset, name, value): # pragma: no cover
152152
class Meta:
153153
model = OAuthSource
154154
fields = [
155+
"pbm_uuid",
155156
"name",
156157
"slug",
157158
"enabled",

authentik/sources/plex/api/source.py

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class PlexSourceViewSet(UsedByMixin, ModelViewSet):
5252
serializer_class = PlexSourceSerializer
5353
lookup_field = "slug"
5454
filterset_fields = [
55+
"pbm_uuid",
5556
"name",
5657
"slug",
5758
"enabled",

authentik/sources/saml/api/source.py

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class SAMLSourceViewSet(UsedByMixin, ModelViewSet):
4444
serializer_class = SAMLSourceSerializer
4545
lookup_field = "slug"
4646
filterset_fields = [
47+
"pbm_uuid",
4748
"name",
4849
"slug",
4950
"enabled",

authentik/sources/scim/api/sources.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ class SCIMSourceViewSet(UsedByMixin, ModelViewSet):
5353
queryset = SCIMSource.objects.all()
5454
serializer_class = SCIMSourceSerializer
5555
lookup_field = "slug"
56-
filterset_fields = ["name", "slug"]
56+
filterset_fields = ["pbm_uuid", "name", "slug"]
5757
search_fields = ["name", "slug", "token__identifier", "token__user__username"]
5858
ordering = ["name"]

schema.yml

+30
Original file line numberDiff line numberDiff line change
@@ -26248,6 +26248,11 @@ paths:
2624826248
name: password_login_update_internal_password
2624926249
schema:
2625026250
type: boolean
26251+
- in: query
26252+
name: pbm_uuid
26253+
schema:
26254+
type: string
26255+
format: uuid
2625126256
- in: query
2625226257
name: realm
2625326258
schema:
@@ -26620,6 +26625,11 @@ paths:
2662026625
name: password_login_update_internal_password
2662126626
schema:
2662226627
type: boolean
26628+
- in: query
26629+
name: pbm_uuid
26630+
schema:
26631+
type: string
26632+
format: uuid
2662326633
- in: query
2662426634
name: peer_certificate
2662526635
schema:
@@ -27049,6 +27059,11 @@ paths:
2704927059
description: Number of results to return per page.
2705027060
schema:
2705127061
type: integer
27062+
- in: query
27063+
name: pbm_uuid
27064+
schema:
27065+
type: string
27066+
format: uuid
2705227067
- in: query
2705327068
name: policy_engine_mode
2705427069
schema:
@@ -27418,6 +27433,11 @@ paths:
2741827433
description: Number of results to return per page.
2741927434
schema:
2742027435
type: integer
27436+
- in: query
27437+
name: pbm_uuid
27438+
schema:
27439+
type: string
27440+
format: uuid
2742127441
- in: query
2742227442
name: policy_engine_mode
2742327443
schema:
@@ -27821,6 +27841,11 @@ paths:
2782127841
description: Number of results to return per page.
2782227842
schema:
2782327843
type: integer
27844+
- in: query
27845+
name: pbm_uuid
27846+
schema:
27847+
type: string
27848+
format: uuid
2782427849
- in: query
2782527850
name: policy_engine_mode
2782627851
schema:
@@ -28184,6 +28209,11 @@ paths:
2818428209
description: Number of results to return per page.
2818528210
schema:
2818628211
type: integer
28212+
- in: query
28213+
name: pbm_uuid
28214+
schema:
28215+
type: string
28216+
format: uuid
2818728217
- name: search
2818828218
required: false
2818928219
in: query

web/src/admin/providers/oauth2/OAuth2Sources.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { DualSelectPair } from "@goauthentik/elements/ak-dual-select/types";
44
import { OAuthSource, SourcesApi } from "@goauthentik/api";
55

66
const sourceToSelect = (source: OAuthSource) => [
7-
source.slug,
7+
source.pk,
88
`${source.name} (${source.slug})`,
99
source.name,
1010
source,
@@ -37,13 +37,15 @@ export function oauth2SourcesSelector(instanceMappings?: string[]) {
3737
const oauthSources = new SourcesApi(DEFAULT_CONFIG);
3838
const mappings = await Promise.allSettled(
3939
instanceMappings.map((instanceId) =>
40-
oauthSources.sourcesOauthRetrieve({ slug: instanceId }),
40+
oauthSources.sourcesOauthList({ pbmUuid: instanceId }),
4141
),
4242
);
4343

4444
return mappings
4545
.filter((s) => s.status === "fulfilled")
4646
.map((s) => s.value)
47+
.filter((s) => s.pagination.count > 0)
48+
.map((s) => s.results[0])
4749
.map(sourceToSelect);
4850
};
4951
}

0 commit comments

Comments
 (0)