@adobe/helix-config 2.15.0 → 2.16.0
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 +14 -0
- package/package.json +2 -2
- package/src/config-view.js +16 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [2.16.0](https://github.com/adobe/helix-config/compare/v2.15.1...v2.16.0) (2024-05-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add global token hash if needed ([#76](https://github.com/adobe/helix-config/issues/76)) ([ac4a139](https://github.com/adobe/helix-config/commit/ac4a139497a98302ef9627644f5b9918ee76c282))
|
|
7
|
+
|
|
8
|
+
## [2.15.1](https://github.com/adobe/helix-config/compare/v2.15.0...v2.15.1) (2024-05-07)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* do not load org config in resolveConfig ([ccedbfd](https://github.com/adobe/helix-config/commit/ccedbfd4c7c465b842e25f9021fd5a06021e63d4))
|
|
14
|
+
|
|
1
15
|
# [2.15.0](https://github.com/adobe/helix-config/compare/v2.14.0...v2.15.0) (2024-05-07)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-config",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"description": "Helix Config",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
12
|
"scripts": {
|
|
13
|
-
"test": "c8 mocha",
|
|
13
|
+
"test": "c8 mocha --spec 'test/**/*.test.js'",
|
|
14
14
|
"lint": "eslint .",
|
|
15
15
|
"docs:types": "node ./test/dev/generate-types.js",
|
|
16
16
|
"semantic-release": "semantic-release",
|
package/src/config-view.js
CHANGED
|
@@ -66,7 +66,7 @@ export function canonicalArrayString(root, partition, prop) {
|
|
|
66
66
|
/**
|
|
67
67
|
* Returns the normalized access configuration for the give partition.
|
|
68
68
|
*/
|
|
69
|
-
export function getAccessConfig(config, partition) {
|
|
69
|
+
export function getAccessConfig(ctx, config, partition) {
|
|
70
70
|
const { access, tokens = {} } = config;
|
|
71
71
|
const apiKeyId = toArray(access[partition]?.apiKeyId ?? access.apiKeyId);
|
|
72
72
|
const allow = toArray(access[partition]?.allow ?? access.allow);
|
|
@@ -84,11 +84,20 @@ export function getAccessConfig(config, partition) {
|
|
|
84
84
|
if (allow.length && !cfg.apiKeyId.length) {
|
|
85
85
|
cfg.apiKeyId.push('dummy');
|
|
86
86
|
}
|
|
87
|
-
|
|
88
|
-
// enforced.
|
|
89
|
-
if (cfg.apiKeyId.length
|
|
90
|
-
|
|
87
|
+
|
|
88
|
+
// if an apiKeyId is defined but no tokenHash, create a fake one so that auth is still enforced.
|
|
89
|
+
if (cfg.apiKeyId.length) {
|
|
90
|
+
// add global token hash if defined and needed
|
|
91
|
+
const globalTokenHash = ctx.env.HLX_GLOBAL_TOKEN_HASH;
|
|
92
|
+
if (cfg.tokenHash.length && globalTokenHash) {
|
|
93
|
+
// augment the list of hashes with the global one if exists
|
|
94
|
+
cfg.tokenHash.push(globalTokenHash);
|
|
95
|
+
} else if (!cfg.tokenHash.length) {
|
|
96
|
+
// add a dummy or global hash if no tokens match the apiKeyIds.
|
|
97
|
+
cfg.tokenHash.push(globalTokenHash || 'n/a');
|
|
98
|
+
}
|
|
91
99
|
}
|
|
100
|
+
|
|
92
101
|
// todo: remove after auth rewrite
|
|
93
102
|
if (allow) {
|
|
94
103
|
cfg.allow = allow;
|
|
@@ -203,16 +212,6 @@ async function resolveConfig(ctx, rso, scope) {
|
|
|
203
212
|
if (scope === SCOPE_PIPELINE || scope === SCOPE_DELIVERY) {
|
|
204
213
|
config.head = await loadHeadHtml(ctx, config, rso.ref);
|
|
205
214
|
}
|
|
206
|
-
|
|
207
|
-
// check for org config
|
|
208
|
-
const orgKey = `orgs/${rso.org}/config.json`;
|
|
209
|
-
res = await ctx.loader.getObject(HELIX_CONFIG_BUS, orgKey);
|
|
210
|
-
if (res.body) {
|
|
211
|
-
const orgConfig = res.json();
|
|
212
|
-
if (orgConfig.tokens) {
|
|
213
|
-
config.tokens = orgConfig.tokens;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
215
|
return config;
|
|
217
216
|
}
|
|
218
217
|
|
|
@@ -265,8 +264,8 @@ export async function getConfigResponse(ctx, opts) {
|
|
|
265
264
|
// normalize access config
|
|
266
265
|
const { admin = {} } = config.access;
|
|
267
266
|
config.access = {
|
|
268
|
-
preview: getAccessConfig(config, 'preview'),
|
|
269
|
-
live: getAccessConfig(config, 'live'),
|
|
267
|
+
preview: getAccessConfig(ctx, config, 'preview'),
|
|
268
|
+
live: getAccessConfig(ctx, config, 'live'),
|
|
270
269
|
// access.require.repository ?
|
|
271
270
|
};
|
|
272
271
|
if (opts.scope === SCOPE_ADMIN || opts.scope === SCOPE_RAW) {
|