Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sources: allow uuid or slug to be used for retrieving a source #12780

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions authentik/sources/kerberos/api/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class KerberosSourceViewSet(UsedByMixin, ModelViewSet):
serializer_class = KerberosSourceSerializer
lookup_field = "slug"
filterset_fields = [
"pbm_uuid",
"name",
"slug",
"enabled",
Expand Down
1 change: 1 addition & 0 deletions authentik/sources/ldap/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class LDAPSourceViewSet(UsedByMixin, ModelViewSet):
serializer_class = LDAPSourceSerializer
lookup_field = "slug"
filterset_fields = [
"pbm_uuid",
"name",
"slug",
"enabled",
Expand Down
1 change: 1 addition & 0 deletions authentik/sources/oauth/api/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def filter_has_jwks(self, queryset, name, value): # pragma: no cover
class Meta:
model = OAuthSource
fields = [
"pbm_uuid",
"name",
"slug",
"enabled",
Expand Down
1 change: 1 addition & 0 deletions authentik/sources/plex/api/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class PlexSourceViewSet(UsedByMixin, ModelViewSet):
serializer_class = PlexSourceSerializer
lookup_field = "slug"
filterset_fields = [
"pbm_uuid",
"name",
"slug",
"enabled",
Expand Down
1 change: 1 addition & 0 deletions authentik/sources/saml/api/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class SAMLSourceViewSet(UsedByMixin, ModelViewSet):
serializer_class = SAMLSourceSerializer
lookup_field = "slug"
filterset_fields = [
"pbm_uuid",
"name",
"slug",
"enabled",
Expand Down
2 changes: 1 addition & 1 deletion authentik/sources/scim/api/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@
queryset = SCIMSource.objects.all()
serializer_class = SCIMSourceSerializer
lookup_field = "slug"
filterset_fields = ["name", "slug"]
filterset_fields = ["pbm_uuid", "name", "slug"]

Check warning on line 56 in authentik/sources/scim/api/sources.py

View check run for this annotation

Codecov / codecov/patch

authentik/sources/scim/api/sources.py#L56

Added line #L56 was not covered by tests
search_fields = ["name", "slug", "token__identifier", "token__user__username"]
ordering = ["name"]
30 changes: 30 additions & 0 deletions schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26248,6 +26248,11 @@ paths:
name: password_login_update_internal_password
schema:
type: boolean
- in: query
name: pbm_uuid
schema:
type: string
format: uuid
- in: query
name: realm
schema:
Expand Down Expand Up @@ -26620,6 +26625,11 @@ paths:
name: password_login_update_internal_password
schema:
type: boolean
- in: query
name: pbm_uuid
schema:
type: string
format: uuid
- in: query
name: peer_certificate
schema:
Expand Down Expand Up @@ -27049,6 +27059,11 @@ paths:
description: Number of results to return per page.
schema:
type: integer
- in: query
name: pbm_uuid
schema:
type: string
format: uuid
- in: query
name: policy_engine_mode
schema:
Expand Down Expand Up @@ -27418,6 +27433,11 @@ paths:
description: Number of results to return per page.
schema:
type: integer
- in: query
name: pbm_uuid
schema:
type: string
format: uuid
- in: query
name: policy_engine_mode
schema:
Expand Down Expand Up @@ -27821,6 +27841,11 @@ paths:
description: Number of results to return per page.
schema:
type: integer
- in: query
name: pbm_uuid
schema:
type: string
format: uuid
- in: query
name: policy_engine_mode
schema:
Expand Down Expand Up @@ -28184,6 +28209,11 @@ paths:
description: Number of results to return per page.
schema:
type: integer
- in: query
name: pbm_uuid
schema:
type: string
format: uuid
- name: search
required: false
in: query
Expand Down
6 changes: 4 additions & 2 deletions web/src/admin/providers/oauth2/OAuth2Sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DualSelectPair } from "@goauthentik/elements/ak-dual-select/types";
import { OAuthSource, SourcesApi } from "@goauthentik/api";

const sourceToSelect = (source: OAuthSource) => [
source.slug,
source.pk,
`${source.name} (${source.slug})`,
source.name,
source,
Expand Down Expand Up @@ -37,13 +37,15 @@ export function oauth2SourcesSelector(instanceMappings?: string[]) {
const oauthSources = new SourcesApi(DEFAULT_CONFIG);
const mappings = await Promise.allSettled(
instanceMappings.map((instanceId) =>
oauthSources.sourcesOauthRetrieve({ slug: instanceId }),
oauthSources.sourcesOauthList({ pbmUuid: instanceId }),
),
);

return mappings
.filter((s) => s.status === "fulfilled")
.map((s) => s.value)
.filter((s) => s.pagination.count > 0)
.map((s) => s.results[0])
.map(sourceToSelect);
};
}
Loading