@adobe/helix-config 2.11.0 → 2.11.1
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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/config-legacy.js +33 -1
- package/src/config-view.js +7 -12
- package/src/schemas/access-admin.schema.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [2.11.1](https://github.com/adobe/helix-config/compare/v2.11.0...v2.11.1) (2024-04-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* cleanup admin.access ([#66](https://github.com/adobe/helix-config/issues/66)) ([28b1c28](https://github.com/adobe/helix-config/commit/28b1c28a71894b98e7748f3c671e4a79879ae81b))
|
|
7
|
+
|
|
1
8
|
# [2.11.0](https://github.com/adobe/helix-config/compare/v2.10.4...v2.11.0) (2024-04-29)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/config-legacy.js
CHANGED
|
@@ -15,6 +15,13 @@ const HELIX_CODE_BUS = 'helix-code-bus';
|
|
|
15
15
|
|
|
16
16
|
const HELIX_CONTENT_BUS = 'helix-content-bus';
|
|
17
17
|
|
|
18
|
+
export function toArray(v) {
|
|
19
|
+
if (!v) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
return Array.isArray(v) ? v : [v];
|
|
23
|
+
}
|
|
24
|
+
|
|
18
25
|
/**
|
|
19
26
|
* Retrieves the helix-config.json which is an aggregate from fstab.yaml and head.html.
|
|
20
27
|
*
|
|
@@ -79,6 +86,23 @@ export async function fetchRobotsTxt(ctx, owner, repo) {
|
|
|
79
86
|
return res.body;
|
|
80
87
|
}
|
|
81
88
|
|
|
89
|
+
async function resolveAdminAccess(ctx, admin) {
|
|
90
|
+
const ret = {
|
|
91
|
+
...admin,
|
|
92
|
+
};
|
|
93
|
+
if (ret.apiKeyId) {
|
|
94
|
+
ret.apiKeyId = toArray(ret.apiKeyId);
|
|
95
|
+
}
|
|
96
|
+
if (ret.defaultRole) {
|
|
97
|
+
ret.defaultRole = toArray(ret.defaultRole);
|
|
98
|
+
}
|
|
99
|
+
for (const [role, users] of Object.entries(ret.role ?? [])) {
|
|
100
|
+
// todo: load users.json
|
|
101
|
+
ret.role[role] = toArray(users);
|
|
102
|
+
}
|
|
103
|
+
return ret;
|
|
104
|
+
}
|
|
105
|
+
|
|
82
106
|
/**
|
|
83
107
|
* Loads the content from a helix 4 project.
|
|
84
108
|
* @param {ConfigContext} ctx
|
|
@@ -101,6 +125,8 @@ export async function resolveLegacyConfig(ctx, rso, scope) {
|
|
|
101
125
|
: 'onedrive',
|
|
102
126
|
url: source,
|
|
103
127
|
};
|
|
128
|
+
} else {
|
|
129
|
+
delete source.contentBusId;
|
|
104
130
|
}
|
|
105
131
|
const config = {
|
|
106
132
|
version: 1,
|
|
@@ -122,10 +148,16 @@ export async function resolveLegacyConfig(ctx, rso, scope) {
|
|
|
122
148
|
};
|
|
123
149
|
const configAllPreview = await fetchConfigAll(ctx, config.content.contentBusId, 'preview');
|
|
124
150
|
const configAllLive = await fetchConfigAll(ctx, config.content.contentBusId, 'live');
|
|
125
|
-
const { access } = configAllPreview?.config?.data || {};
|
|
151
|
+
const { access, admin } = configAllPreview?.config?.data || {};
|
|
126
152
|
if (access) {
|
|
127
153
|
config.access = access;
|
|
128
154
|
}
|
|
155
|
+
if (admin) {
|
|
156
|
+
if (!config.access) {
|
|
157
|
+
config.access = { };
|
|
158
|
+
}
|
|
159
|
+
config.access.admin = await resolveAdminAccess(ctx, admin);
|
|
160
|
+
}
|
|
129
161
|
if (configAllPreview) {
|
|
130
162
|
config.cdn = configAllPreview.config?.data.cdn ?? {};
|
|
131
163
|
if (!config.cdn.prod?.host && configAllPreview.config?.data.host) {
|
package/src/config-view.js
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
SCOPE_DELIVERY,
|
|
19
19
|
SCOPE_RAW,
|
|
20
20
|
} from './ConfigContext.js';
|
|
21
|
-
import { resolveLegacyConfig, fetchRobotsTxt } from './config-legacy.js';
|
|
21
|
+
import { resolveLegacyConfig, fetchRobotsTxt, toArray } from './config-legacy.js';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* @typedef Config
|
|
@@ -45,13 +45,6 @@ const HELIX_CONFIG_BUS = 'helix-config-bus';
|
|
|
45
45
|
|
|
46
46
|
const HELIX_CONTENT_BUS = 'helix-content-bus';
|
|
47
47
|
|
|
48
|
-
export function toArray(v) {
|
|
49
|
-
if (!v) {
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
|
-
return Array.isArray(v) ? v : [v];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
48
|
/**
|
|
56
49
|
* Creates a string representation of the given array that is suitable for substring matching by
|
|
57
50
|
* delimiting each entry with `,` eg: ,foo@adobe.com,bar@adobe.com,
|
|
@@ -75,8 +68,8 @@ export function canonicalArrayString(root, partition, prop) {
|
|
|
75
68
|
export function getAccessConfig(config, partition) {
|
|
76
69
|
const { access, tokens = {} } = config;
|
|
77
70
|
const apiKeyId = toArray(access[partition]?.apiKeyId ?? access.apiKeyId);
|
|
71
|
+
const allow = toArray(access[partition]?.allow ?? access.allow);
|
|
78
72
|
const cfg = {
|
|
79
|
-
allow: toArray(access[partition]?.allow ?? access.allow),
|
|
80
73
|
apiKeyId,
|
|
81
74
|
tokenHash: apiKeyId
|
|
82
75
|
// token ids are always stored in base64url format, but legacy apiKeyIds are not
|
|
@@ -87,7 +80,7 @@ export function getAccessConfig(config, partition) {
|
|
|
87
80
|
};
|
|
88
81
|
// if an allow is defined but no apiKeyId, create a fake one so that auth is still
|
|
89
82
|
// enforced. later we can remove the allow and the apiKeyId in favor of the tokenHash
|
|
90
|
-
if (
|
|
83
|
+
if (allow.length && !cfg.apiKeyId.length) {
|
|
91
84
|
cfg.apiKeyId.push('fake');
|
|
92
85
|
}
|
|
93
86
|
// if an apiKeyId is defined but no tokenHash, create a fake one so that auth is still
|
|
@@ -95,6 +88,10 @@ export function getAccessConfig(config, partition) {
|
|
|
95
88
|
if (cfg.apiKeyId.length && !cfg.tokenHash.length) {
|
|
96
89
|
cfg.tokenHash.push('n/a');
|
|
97
90
|
}
|
|
91
|
+
// todo: remove after auth rewrite
|
|
92
|
+
if (allow) {
|
|
93
|
+
cfg.allow = allow;
|
|
94
|
+
}
|
|
98
95
|
return cfg;
|
|
99
96
|
}
|
|
100
97
|
|
|
@@ -277,8 +274,6 @@ export async function getConfigResponse(ctx, opts) {
|
|
|
277
274
|
const adminConfig = {
|
|
278
275
|
...rso,
|
|
279
276
|
...config,
|
|
280
|
-
// todo: delete after admin uses new structure
|
|
281
|
-
contentBusId: config.content.contentBusId,
|
|
282
277
|
content: {
|
|
283
278
|
...config.content,
|
|
284
279
|
...config.content.source,
|