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

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L.
2025-01-23 12:26:58 +01:00
committed by GitHub
parent ce7e539f59
commit 1ce3dfd17f
8 changed files with 40 additions and 3 deletions

View File

@ -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,
@ -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);
};
}