@camstack/addon-auth 1.2.147 → 1.2.149
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{dist-DDdB_Mme.js → dist-Bo_LXyeR.js} +1549 -56
- package/dist/{dist-BGsjH-S3.mjs → dist-DqNfCE-z.mjs} +1520 -57
- package/dist/oidc/auth-oidc.addon.js +135 -13
- package/dist/oidc/auth-oidc.addon.mjs +135 -13
- package/dist/webauthn/_stub.js +304 -235
- package/dist/webauthn/{_virtual_mf-localSharedImportMap___mfe_internal__addon_auth_webauthn_widgets-DiKn9eAB.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_auth_webauthn_widgets-SIs0w9js.mjs} +3 -3
- package/dist/webauthn/_virtual_mf___mfe_internal__addon_auth_webauthn_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-BpOR-FRf.mjs +26 -0
- package/dist/webauthn/auth-webauthn.addon.js +160 -53
- package/dist/webauthn/auth-webauthn.addon.mjs +160 -53
- package/dist/webauthn/{hostInit-Cf9MrMyw.mjs → hostInit-DZMo0Gc_.mjs} +3 -3
- package/dist/webauthn/remoteEntry.js +1 -1
- package/package.json +1 -1
- package/dist/webauthn/_virtual_mf___mfe_internal__addon_auth_webauthn_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-C_j9tv24.mjs +0 -26
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_dist = require("../dist-
|
|
5
|
+
const require_dist = require("../dist-Bo_LXyeR.js");
|
|
6
6
|
let node_crypto = require("node:crypto");
|
|
7
7
|
node_crypto = require_dist.__toESM(node_crypto);
|
|
8
8
|
//#region ../../node_modules/jose/dist/webapi/lib/buffer_utils.js
|
|
@@ -886,6 +886,90 @@ function clientSecretPatchOf(value) {
|
|
|
886
886
|
return { clientSecret: value };
|
|
887
887
|
}
|
|
888
888
|
//#endregion
|
|
889
|
+
//#region src/oidc/oidc-provider-record-kinds.ts
|
|
890
|
+
var OIDC_PROVIDER_KIND = "oidc-provider";
|
|
891
|
+
var usernameClaimSchema = require_dist._enum([
|
|
892
|
+
"preferred_username",
|
|
893
|
+
"email",
|
|
894
|
+
"sub"
|
|
895
|
+
]);
|
|
896
|
+
var OidcProviderBodySchema = require_dist.object({
|
|
897
|
+
displayName: require_dist.string().min(1),
|
|
898
|
+
icon: require_dist.string(),
|
|
899
|
+
issuerUrl: require_dist.string(),
|
|
900
|
+
clientId: require_dist.string(),
|
|
901
|
+
clientSecret: require_dist.string().meta({ secret: true }),
|
|
902
|
+
redirectUri: require_dist.string(),
|
|
903
|
+
scopes: require_dist.string(),
|
|
904
|
+
usernameClaim: usernameClaimSchema
|
|
905
|
+
});
|
|
906
|
+
var oidcProviderEntryKind = require_dist.defineEntryKind(OIDC_PROVIDER_KIND, {
|
|
907
|
+
title: "OIDC providers",
|
|
908
|
+
nameField: "displayName",
|
|
909
|
+
schema: OidcProviderBodySchema,
|
|
910
|
+
writeTrigger: "an operator adds, edits or removes an OpenID Connect identity provider",
|
|
911
|
+
adoptsFrom: require_dist.settingsArrayAdoptsFrom("auth-oidc", "providers")
|
|
912
|
+
});
|
|
913
|
+
//#endregion
|
|
914
|
+
//#region src/oidc/oidc-provider-store.ts
|
|
915
|
+
function rowToProvider(id, data) {
|
|
916
|
+
return {
|
|
917
|
+
...DEFAULT_OIDC_PROVIDER,
|
|
918
|
+
...data,
|
|
919
|
+
id
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
var OidcProviderStore = class OidcProviderStore {
|
|
923
|
+
kind;
|
|
924
|
+
constructor(kind) {
|
|
925
|
+
this.kind = kind;
|
|
926
|
+
}
|
|
927
|
+
static of(records) {
|
|
928
|
+
return new OidcProviderStore(records.kind(oidcProviderEntryKind));
|
|
929
|
+
}
|
|
930
|
+
async listResolved() {
|
|
931
|
+
const page = await this.kind.query({ limit: 1e3 });
|
|
932
|
+
const out = [];
|
|
933
|
+
for (const record of page.records) {
|
|
934
|
+
let data = record.data;
|
|
935
|
+
try {
|
|
936
|
+
const resolved = await this.kind.getResolved(record.id);
|
|
937
|
+
if (resolved !== null) data = resolved.data;
|
|
938
|
+
} catch (err) {
|
|
939
|
+
if (!(err instanceof require_dist.RecordSecretUnavailableError)) throw err;
|
|
940
|
+
}
|
|
941
|
+
const parsed = OidcProviderBodySchema.safeParse(data);
|
|
942
|
+
if (!parsed.success) continue;
|
|
943
|
+
out.push(rowToProvider(record.id, parsed.data));
|
|
944
|
+
}
|
|
945
|
+
return out;
|
|
946
|
+
}
|
|
947
|
+
async replaceAll(providers) {
|
|
948
|
+
const page = await this.kind.query({ limit: 1e3 });
|
|
949
|
+
const nextIds = new Set(providers.map((p) => p.id));
|
|
950
|
+
for (const row of page.records) if (!nextIds.has(row.id)) await this.kind.delete(row.id);
|
|
951
|
+
for (const row of providers) {
|
|
952
|
+
const { id, displayName, icon, issuerUrl, clientId, clientSecret, redirectUri, scopes, usernameClaim } = row;
|
|
953
|
+
const body = {
|
|
954
|
+
displayName,
|
|
955
|
+
icon,
|
|
956
|
+
issuerUrl,
|
|
957
|
+
clientId,
|
|
958
|
+
clientSecret,
|
|
959
|
+
redirectUri,
|
|
960
|
+
scopes,
|
|
961
|
+
usernameClaim
|
|
962
|
+
};
|
|
963
|
+
const parsed = oidcProviderEntryKind.schema.safeParse(body);
|
|
964
|
+
if (!parsed.success) throw new Error(`invalid OIDC provider '${id}': ${parsed.error.message}`);
|
|
965
|
+
await this.kind.put({
|
|
966
|
+
id,
|
|
967
|
+
data: parsed.data
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
};
|
|
972
|
+
//#endregion
|
|
889
973
|
//#region src/oidc/auth-oidc.addon.ts
|
|
890
974
|
/**
|
|
891
975
|
* Generic OpenID Connect (OIDC) authentication provider.
|
|
@@ -976,6 +1060,8 @@ function returnBaseOf(redirectUri, callbackPath) {
|
|
|
976
1060
|
var AuthOidcAddon = class extends require_dist.BaseAddon {
|
|
977
1061
|
/** Per-provider runtime state, keyed by `provider.id`. */
|
|
978
1062
|
instances = /* @__PURE__ */ new Map();
|
|
1063
|
+
providerStore = null;
|
|
1064
|
+
activeProviders = [];
|
|
979
1065
|
/** Pending OAuth states across ALL providers. The pending entry
|
|
980
1066
|
* carries `providerId` so the /callback handler picks the right config. */
|
|
981
1067
|
pendingStates = /* @__PURE__ */ new Map();
|
|
@@ -985,9 +1071,24 @@ var AuthOidcAddon = class extends require_dist.BaseAddon {
|
|
|
985
1071
|
super({ ...DEFAULT_CONFIG });
|
|
986
1072
|
}
|
|
987
1073
|
async onConfigChanged() {
|
|
1074
|
+
this.activeProviders = await this.loadPersistedProviders();
|
|
988
1075
|
this.rebuildInstances();
|
|
989
1076
|
}
|
|
990
1077
|
async onInitialize() {
|
|
1078
|
+
const records = this.ctx.records;
|
|
1079
|
+
if (records === void 0) throw new Error("auth-oidc: ctx.records is required (hub-only addon)");
|
|
1080
|
+
await records.declare({ "oidc-provider": oidcProviderEntryKind });
|
|
1081
|
+
this.providerStore = OidcProviderStore.of(records);
|
|
1082
|
+
this.activeProviders = await this.loadPersistedProviders();
|
|
1083
|
+
if ((await this.providerStore.listResolved()).length === 0 && this.config.providers.length > 0) try {
|
|
1084
|
+
await this.providerStore.replaceAll(this.config.providers);
|
|
1085
|
+
this.activeProviders = await this.loadPersistedProviders();
|
|
1086
|
+
} catch (err) {
|
|
1087
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1088
|
+
if (!msg.startsWith("records/foreign-marker:") && !msg.startsWith("records/adoption-pending:")) throw err;
|
|
1089
|
+
this.ctx.logger.warn("OIDC: deferred config→records migrate (secret markers need adopt remap)", { meta: { error: msg } });
|
|
1090
|
+
this.activeProviders = [...this.config.providers];
|
|
1091
|
+
}
|
|
991
1092
|
this.rebuildInstances();
|
|
992
1093
|
const authProvider = {
|
|
993
1094
|
validateCredentials: async () => null,
|
|
@@ -1045,7 +1146,7 @@ var AuthOidcAddon = class extends require_dist.BaseAddon {
|
|
|
1045
1146
|
connectionFormSchema: async () => OIDC_CONNECTION_FORM_SCHEMA,
|
|
1046
1147
|
listConnections: async () => {
|
|
1047
1148
|
const secrets = this.ctx.secrets;
|
|
1048
|
-
return this.
|
|
1149
|
+
return this.activeProviders.map((row) => {
|
|
1049
1150
|
const merged = {
|
|
1050
1151
|
...DEFAULT_PROVIDER,
|
|
1051
1152
|
...row
|
|
@@ -1071,15 +1172,15 @@ var AuthOidcAddon = class extends require_dist.BaseAddon {
|
|
|
1071
1172
|
});
|
|
1072
1173
|
},
|
|
1073
1174
|
createConnection: async (input) => {
|
|
1074
|
-
const result = createOidcConnection(this.
|
|
1175
|
+
const result = createOidcConnection(this.providersConfig(), input);
|
|
1075
1176
|
if (!result.ok) throw new Error(result.reason === "duplicate-id" ? `An OIDC connection with id "${input.id}" already exists` : `Invalid connection id "${input.id}" — use a lowercase slug`);
|
|
1076
|
-
await this.
|
|
1177
|
+
await this.persistProviders(result.config.providers);
|
|
1077
1178
|
this.rebuildInstances();
|
|
1078
1179
|
return { id: result.id };
|
|
1079
1180
|
},
|
|
1080
1181
|
updateConnection: async (input) => {
|
|
1081
1182
|
const secretPatch = clientSecretPatchOf(input.clientSecret);
|
|
1082
|
-
const result = updateOidcConnection(this.
|
|
1183
|
+
const result = updateOidcConnection(this.providersConfig(), input.id, {
|
|
1083
1184
|
displayName: input.displayName,
|
|
1084
1185
|
...input.icon !== void 0 ? { icon: input.icon } : {},
|
|
1085
1186
|
...input.issuerUrl !== void 0 ? { issuerUrl: input.issuerUrl } : {},
|
|
@@ -1095,20 +1196,21 @@ var AuthOidcAddon = class extends require_dist.BaseAddon {
|
|
|
1095
1196
|
...p,
|
|
1096
1197
|
clientSecret: require_dist.SECRET_CLEAR
|
|
1097
1198
|
} : p);
|
|
1098
|
-
await this.
|
|
1099
|
-
} else await this.
|
|
1199
|
+
await this.persistProviders(cleared);
|
|
1200
|
+
} else await this.persistProviders(result.config.providers);
|
|
1100
1201
|
this.rebuildInstances();
|
|
1101
1202
|
return { ok: true };
|
|
1102
1203
|
},
|
|
1103
1204
|
deleteConnection: async (input) => {
|
|
1104
|
-
if (findOidcProvider(this.
|
|
1105
|
-
|
|
1205
|
+
if (findOidcProvider(this.providersConfig(), input.id) === null) throw new Error(`Unknown OIDC connection "${input.id}"`);
|
|
1206
|
+
const cleared = this.activeProviders.map((p) => p.id === input.id ? {
|
|
1106
1207
|
...p,
|
|
1107
1208
|
clientSecret: require_dist.SECRET_CLEAR
|
|
1108
|
-
} : p)
|
|
1109
|
-
|
|
1209
|
+
} : p);
|
|
1210
|
+
await this.persistProviders(cleared);
|
|
1211
|
+
const result = deleteOidcConnection(this.providersConfig(), input.id);
|
|
1110
1212
|
if (!result.ok) throw new Error(`Unknown OIDC connection "${input.id}"`);
|
|
1111
|
-
await this.
|
|
1213
|
+
await this.persistProviders(result.config.providers);
|
|
1112
1214
|
this.rebuildInstances();
|
|
1113
1215
|
return { ok: true };
|
|
1114
1216
|
}
|
|
@@ -1147,9 +1249,29 @@ var AuthOidcAddon = class extends require_dist.BaseAddon {
|
|
|
1147
1249
|
fields: []
|
|
1148
1250
|
}] });
|
|
1149
1251
|
}
|
|
1252
|
+
providersConfig() {
|
|
1253
|
+
return { providers: this.activeProviders };
|
|
1254
|
+
}
|
|
1255
|
+
async loadPersistedProviders() {
|
|
1256
|
+
const store = this.providerStore;
|
|
1257
|
+
if (store !== null) {
|
|
1258
|
+
const fromRecords = await store.listResolved();
|
|
1259
|
+
if (fromRecords.length > 0) return fromRecords;
|
|
1260
|
+
}
|
|
1261
|
+
return this.config.providers;
|
|
1262
|
+
}
|
|
1263
|
+
async persistProviders(providers) {
|
|
1264
|
+
this.activeProviders = [...providers];
|
|
1265
|
+
const store = this.providerStore;
|
|
1266
|
+
if (store !== null) {
|
|
1267
|
+
await store.replaceAll(providers);
|
|
1268
|
+
return;
|
|
1269
|
+
}
|
|
1270
|
+
await this.updateGlobalSettings({ providers: [...providers] });
|
|
1271
|
+
}
|
|
1150
1272
|
rebuildInstances() {
|
|
1151
1273
|
this.instances.clear();
|
|
1152
|
-
const providers = this.
|
|
1274
|
+
const providers = this.activeProviders;
|
|
1153
1275
|
for (const raw of providers) {
|
|
1154
1276
|
const merged = {
|
|
1155
1277
|
...DEFAULT_PROVIDER,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { A as settingsArrayAdoptsFrom, C as SECRET_CLEAR, D as globalSecretScope, I as object, L as string, M as _enum, O as isSecretClear, S as RecordSecretUnavailableError, T as defineEntryKind, _ as requestMountPrefix, b as errMsg, c as authProviderCapability, d as loginMethodCapability, f as normalizeOrigin, g as pickRequestOrigin, h as parseAppPageLang, i as addonRoutesCapability, j as toSecretFieldView, k as isSecretMarker, l as buildAddonRouteProvider, m as parseAppFlowRequest, n as APP_REFUSED_PATH, o as advertisedHubOrigins, p as oidcConnectionsCapability, r as SSO_STATE_COOKIE, s as appFlowLocation, t as APP_FLOW_DEFAULT_REDIRECT, u as claimedRequestOrigins, v as resolveIconKey, w as arrayItemFieldPath, x as BaseAddon } from "../dist-DqNfCE-z.mjs";
|
|
2
2
|
import * as crypto$1 from "node:crypto";
|
|
3
3
|
//#region ../../node_modules/jose/dist/webapi/lib/buffer_utils.js
|
|
4
4
|
var encoder = new TextEncoder(), decoder = new TextDecoder(), strictDecoder = new TextDecoder("utf-8", { fatal: !0 });
|
|
@@ -881,6 +881,90 @@ function clientSecretPatchOf(value) {
|
|
|
881
881
|
return { clientSecret: value };
|
|
882
882
|
}
|
|
883
883
|
//#endregion
|
|
884
|
+
//#region src/oidc/oidc-provider-record-kinds.ts
|
|
885
|
+
var OIDC_PROVIDER_KIND = "oidc-provider";
|
|
886
|
+
var usernameClaimSchema = _enum([
|
|
887
|
+
"preferred_username",
|
|
888
|
+
"email",
|
|
889
|
+
"sub"
|
|
890
|
+
]);
|
|
891
|
+
var OidcProviderBodySchema = object({
|
|
892
|
+
displayName: string().min(1),
|
|
893
|
+
icon: string(),
|
|
894
|
+
issuerUrl: string(),
|
|
895
|
+
clientId: string(),
|
|
896
|
+
clientSecret: string().meta({ secret: true }),
|
|
897
|
+
redirectUri: string(),
|
|
898
|
+
scopes: string(),
|
|
899
|
+
usernameClaim: usernameClaimSchema
|
|
900
|
+
});
|
|
901
|
+
var oidcProviderEntryKind = defineEntryKind(OIDC_PROVIDER_KIND, {
|
|
902
|
+
title: "OIDC providers",
|
|
903
|
+
nameField: "displayName",
|
|
904
|
+
schema: OidcProviderBodySchema,
|
|
905
|
+
writeTrigger: "an operator adds, edits or removes an OpenID Connect identity provider",
|
|
906
|
+
adoptsFrom: settingsArrayAdoptsFrom("auth-oidc", "providers")
|
|
907
|
+
});
|
|
908
|
+
//#endregion
|
|
909
|
+
//#region src/oidc/oidc-provider-store.ts
|
|
910
|
+
function rowToProvider(id, data) {
|
|
911
|
+
return {
|
|
912
|
+
...DEFAULT_OIDC_PROVIDER,
|
|
913
|
+
...data,
|
|
914
|
+
id
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
var OidcProviderStore = class OidcProviderStore {
|
|
918
|
+
kind;
|
|
919
|
+
constructor(kind) {
|
|
920
|
+
this.kind = kind;
|
|
921
|
+
}
|
|
922
|
+
static of(records) {
|
|
923
|
+
return new OidcProviderStore(records.kind(oidcProviderEntryKind));
|
|
924
|
+
}
|
|
925
|
+
async listResolved() {
|
|
926
|
+
const page = await this.kind.query({ limit: 1e3 });
|
|
927
|
+
const out = [];
|
|
928
|
+
for (const record of page.records) {
|
|
929
|
+
let data = record.data;
|
|
930
|
+
try {
|
|
931
|
+
const resolved = await this.kind.getResolved(record.id);
|
|
932
|
+
if (resolved !== null) data = resolved.data;
|
|
933
|
+
} catch (err) {
|
|
934
|
+
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
935
|
+
}
|
|
936
|
+
const parsed = OidcProviderBodySchema.safeParse(data);
|
|
937
|
+
if (!parsed.success) continue;
|
|
938
|
+
out.push(rowToProvider(record.id, parsed.data));
|
|
939
|
+
}
|
|
940
|
+
return out;
|
|
941
|
+
}
|
|
942
|
+
async replaceAll(providers) {
|
|
943
|
+
const page = await this.kind.query({ limit: 1e3 });
|
|
944
|
+
const nextIds = new Set(providers.map((p) => p.id));
|
|
945
|
+
for (const row of page.records) if (!nextIds.has(row.id)) await this.kind.delete(row.id);
|
|
946
|
+
for (const row of providers) {
|
|
947
|
+
const { id, displayName, icon, issuerUrl, clientId, clientSecret, redirectUri, scopes, usernameClaim } = row;
|
|
948
|
+
const body = {
|
|
949
|
+
displayName,
|
|
950
|
+
icon,
|
|
951
|
+
issuerUrl,
|
|
952
|
+
clientId,
|
|
953
|
+
clientSecret,
|
|
954
|
+
redirectUri,
|
|
955
|
+
scopes,
|
|
956
|
+
usernameClaim
|
|
957
|
+
};
|
|
958
|
+
const parsed = oidcProviderEntryKind.schema.safeParse(body);
|
|
959
|
+
if (!parsed.success) throw new Error(`invalid OIDC provider '${id}': ${parsed.error.message}`);
|
|
960
|
+
await this.kind.put({
|
|
961
|
+
id,
|
|
962
|
+
data: parsed.data
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
};
|
|
967
|
+
//#endregion
|
|
884
968
|
//#region src/oidc/auth-oidc.addon.ts
|
|
885
969
|
/**
|
|
886
970
|
* Generic OpenID Connect (OIDC) authentication provider.
|
|
@@ -971,6 +1055,8 @@ function returnBaseOf(redirectUri, callbackPath) {
|
|
|
971
1055
|
var AuthOidcAddon = class extends BaseAddon {
|
|
972
1056
|
/** Per-provider runtime state, keyed by `provider.id`. */
|
|
973
1057
|
instances = /* @__PURE__ */ new Map();
|
|
1058
|
+
providerStore = null;
|
|
1059
|
+
activeProviders = [];
|
|
974
1060
|
/** Pending OAuth states across ALL providers. The pending entry
|
|
975
1061
|
* carries `providerId` so the /callback handler picks the right config. */
|
|
976
1062
|
pendingStates = /* @__PURE__ */ new Map();
|
|
@@ -980,9 +1066,24 @@ var AuthOidcAddon = class extends BaseAddon {
|
|
|
980
1066
|
super({ ...DEFAULT_CONFIG });
|
|
981
1067
|
}
|
|
982
1068
|
async onConfigChanged() {
|
|
1069
|
+
this.activeProviders = await this.loadPersistedProviders();
|
|
983
1070
|
this.rebuildInstances();
|
|
984
1071
|
}
|
|
985
1072
|
async onInitialize() {
|
|
1073
|
+
const records = this.ctx.records;
|
|
1074
|
+
if (records === void 0) throw new Error("auth-oidc: ctx.records is required (hub-only addon)");
|
|
1075
|
+
await records.declare({ "oidc-provider": oidcProviderEntryKind });
|
|
1076
|
+
this.providerStore = OidcProviderStore.of(records);
|
|
1077
|
+
this.activeProviders = await this.loadPersistedProviders();
|
|
1078
|
+
if ((await this.providerStore.listResolved()).length === 0 && this.config.providers.length > 0) try {
|
|
1079
|
+
await this.providerStore.replaceAll(this.config.providers);
|
|
1080
|
+
this.activeProviders = await this.loadPersistedProviders();
|
|
1081
|
+
} catch (err) {
|
|
1082
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1083
|
+
if (!msg.startsWith("records/foreign-marker:") && !msg.startsWith("records/adoption-pending:")) throw err;
|
|
1084
|
+
this.ctx.logger.warn("OIDC: deferred config→records migrate (secret markers need adopt remap)", { meta: { error: msg } });
|
|
1085
|
+
this.activeProviders = [...this.config.providers];
|
|
1086
|
+
}
|
|
986
1087
|
this.rebuildInstances();
|
|
987
1088
|
const authProvider = {
|
|
988
1089
|
validateCredentials: async () => null,
|
|
@@ -1040,7 +1141,7 @@ var AuthOidcAddon = class extends BaseAddon {
|
|
|
1040
1141
|
connectionFormSchema: async () => OIDC_CONNECTION_FORM_SCHEMA,
|
|
1041
1142
|
listConnections: async () => {
|
|
1042
1143
|
const secrets = this.ctx.secrets;
|
|
1043
|
-
return this.
|
|
1144
|
+
return this.activeProviders.map((row) => {
|
|
1044
1145
|
const merged = {
|
|
1045
1146
|
...DEFAULT_PROVIDER,
|
|
1046
1147
|
...row
|
|
@@ -1066,15 +1167,15 @@ var AuthOidcAddon = class extends BaseAddon {
|
|
|
1066
1167
|
});
|
|
1067
1168
|
},
|
|
1068
1169
|
createConnection: async (input) => {
|
|
1069
|
-
const result = createOidcConnection(this.
|
|
1170
|
+
const result = createOidcConnection(this.providersConfig(), input);
|
|
1070
1171
|
if (!result.ok) throw new Error(result.reason === "duplicate-id" ? `An OIDC connection with id "${input.id}" already exists` : `Invalid connection id "${input.id}" — use a lowercase slug`);
|
|
1071
|
-
await this.
|
|
1172
|
+
await this.persistProviders(result.config.providers);
|
|
1072
1173
|
this.rebuildInstances();
|
|
1073
1174
|
return { id: result.id };
|
|
1074
1175
|
},
|
|
1075
1176
|
updateConnection: async (input) => {
|
|
1076
1177
|
const secretPatch = clientSecretPatchOf(input.clientSecret);
|
|
1077
|
-
const result = updateOidcConnection(this.
|
|
1178
|
+
const result = updateOidcConnection(this.providersConfig(), input.id, {
|
|
1078
1179
|
displayName: input.displayName,
|
|
1079
1180
|
...input.icon !== void 0 ? { icon: input.icon } : {},
|
|
1080
1181
|
...input.issuerUrl !== void 0 ? { issuerUrl: input.issuerUrl } : {},
|
|
@@ -1090,20 +1191,21 @@ var AuthOidcAddon = class extends BaseAddon {
|
|
|
1090
1191
|
...p,
|
|
1091
1192
|
clientSecret: SECRET_CLEAR
|
|
1092
1193
|
} : p);
|
|
1093
|
-
await this.
|
|
1094
|
-
} else await this.
|
|
1194
|
+
await this.persistProviders(cleared);
|
|
1195
|
+
} else await this.persistProviders(result.config.providers);
|
|
1095
1196
|
this.rebuildInstances();
|
|
1096
1197
|
return { ok: true };
|
|
1097
1198
|
},
|
|
1098
1199
|
deleteConnection: async (input) => {
|
|
1099
|
-
if (findOidcProvider(this.
|
|
1100
|
-
|
|
1200
|
+
if (findOidcProvider(this.providersConfig(), input.id) === null) throw new Error(`Unknown OIDC connection "${input.id}"`);
|
|
1201
|
+
const cleared = this.activeProviders.map((p) => p.id === input.id ? {
|
|
1101
1202
|
...p,
|
|
1102
1203
|
clientSecret: SECRET_CLEAR
|
|
1103
|
-
} : p)
|
|
1104
|
-
|
|
1204
|
+
} : p);
|
|
1205
|
+
await this.persistProviders(cleared);
|
|
1206
|
+
const result = deleteOidcConnection(this.providersConfig(), input.id);
|
|
1105
1207
|
if (!result.ok) throw new Error(`Unknown OIDC connection "${input.id}"`);
|
|
1106
|
-
await this.
|
|
1208
|
+
await this.persistProviders(result.config.providers);
|
|
1107
1209
|
this.rebuildInstances();
|
|
1108
1210
|
return { ok: true };
|
|
1109
1211
|
}
|
|
@@ -1142,9 +1244,29 @@ var AuthOidcAddon = class extends BaseAddon {
|
|
|
1142
1244
|
fields: []
|
|
1143
1245
|
}] });
|
|
1144
1246
|
}
|
|
1247
|
+
providersConfig() {
|
|
1248
|
+
return { providers: this.activeProviders };
|
|
1249
|
+
}
|
|
1250
|
+
async loadPersistedProviders() {
|
|
1251
|
+
const store = this.providerStore;
|
|
1252
|
+
if (store !== null) {
|
|
1253
|
+
const fromRecords = await store.listResolved();
|
|
1254
|
+
if (fromRecords.length > 0) return fromRecords;
|
|
1255
|
+
}
|
|
1256
|
+
return this.config.providers;
|
|
1257
|
+
}
|
|
1258
|
+
async persistProviders(providers) {
|
|
1259
|
+
this.activeProviders = [...providers];
|
|
1260
|
+
const store = this.providerStore;
|
|
1261
|
+
if (store !== null) {
|
|
1262
|
+
await store.replaceAll(providers);
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
await this.updateGlobalSettings({ providers: [...providers] });
|
|
1266
|
+
}
|
|
1145
1267
|
rebuildInstances() {
|
|
1146
1268
|
this.instances.clear();
|
|
1147
|
-
const providers = this.
|
|
1269
|
+
const providers = this.activeProviders;
|
|
1148
1270
|
for (const raw of providers) {
|
|
1149
1271
|
const merged = {
|
|
1150
1272
|
...DEFAULT_PROVIDER,
|