@voxgig/sdkgen 4.48.1 → 4.49.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/bin/voxgig-sdkgen +1 -1
- package/package.json +1 -1
- package/project/.sdk/model/feature/secrets.aontu +3 -0
- package/project/.sdk/src/cmp/c/Config_c.ts +6 -1
- package/project/.sdk/src/cmp/c/fragment/Entity.fragment.c +0 -10
- package/project/.sdk/src/cmp/clojure/fragment/Entity.fragment.clj +0 -9
- package/project/.sdk/src/cmp/csharp/fragment/EntityBase.fragment.cs +0 -11
- package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +0 -7
- package/project/.sdk/src/cmp/java/fragment/EntityBase.fragment.java +0 -10
- package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +2 -11
- package/project/.sdk/src/cmp/kotlin/fragment/EntityBase.fragment.kt +0 -10
- package/project/.sdk/src/cmp/lua/fragment/Entity.fragment.lua +0 -11
- package/project/.sdk/src/cmp/ocaml/Entity_ocaml.ts +2 -10
- package/project/.sdk/src/cmp/perl/fragment/Entity.fragment.pm +0 -13
- package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +0 -10
- package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +0 -10
- package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +0 -10
- package/project/.sdk/src/cmp/rust/fragment/Entity.fragment.rs +0 -12
- package/project/.sdk/src/cmp/scala/fragment/EntityBase.fragment.scala +0 -10
- package/project/.sdk/src/cmp/swift/fragment/EntityBase.fragment.swift +0 -9
- package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +0 -7
- package/project/.sdk/src/cmp/zig/fragment/Entity.fragment.zig +1 -14
- package/project/.sdk/tm/c/feature/cache.c +16 -1
- package/project/.sdk/tm/c/feature/secrets.c +149 -18
- package/project/.sdk/tm/c/tests/feature/secrets/secrets_test.c +319 -70
- package/project/.sdk/tm/c/tests/feature_test.c +31 -0
- package/project/.sdk/tm/clojure/feature/secrets/sdk/feature/secrets.clj +74 -29
- package/project/.sdk/tm/clojure/src/sdk/core.clj +55 -6
- package/project/.sdk/tm/clojure/src/sdk/features.clj +16 -2
- package/project/.sdk/tm/clojure/test/sdk/test/feature/secrets.clj +191 -48
- package/project/.sdk/tm/clojure/test/sdk/test/feature.clj +16 -0
- package/project/.sdk/tm/cpp/core/types.hpp +1 -11
- package/project/.sdk/tm/cpp/feature/cache.hpp +14 -1
- package/project/.sdk/tm/cpp/feature/secrets.hpp +133 -18
- package/project/.sdk/tm/cpp/test/feature/secrets/secrets_test.cpp +175 -8
- package/project/.sdk/tm/cpp/test/feature_test.cpp +27 -0
- package/project/.sdk/tm/csharp/core/Control.cs +0 -5
- package/project/.sdk/tm/csharp/feature/CacheFeature.cs +16 -0
- package/project/.sdk/tm/csharp/feature/SecretsFeature.cs +77 -38
- package/project/.sdk/tm/csharp/test/FeatureTest.cs +29 -0
- package/project/.sdk/tm/csharp/test/feature/secrets/SecretsFeatureTest.cs +315 -68
- package/project/.sdk/tm/elixir/lib/projectname/entity_base.ex +0 -13
- package/project/.sdk/tm/elixir/lib/projectname/feature/cache.ex +32 -10
- package/project/.sdk/tm/elixir/lib/projectname/feature/secrets.ex +78 -22
- package/project/.sdk/tm/elixir/test/feature/secrets/secrets_test.exs +178 -19
- package/project/.sdk/tm/elixir/test/feature_test.exs +20 -0
- package/project/.sdk/tm/go/feature/cache_feature.go +14 -1
- package/project/.sdk/tm/go/feature/secrets_feature.go +110 -15
- package/project/.sdk/tm/go/test/feature/secrets/secrets_feature_test.go +373 -87
- package/project/.sdk/tm/go/test/feature_test.go +32 -0
- package/project/.sdk/tm/go/utility/media.go +2 -2
- package/project/.sdk/tm/java/core/Control.java +0 -5
- package/project/.sdk/tm/java/feature/CacheFeature.java +12 -0
- package/project/.sdk/tm/java/feature/SecretsFeature.java +104 -34
- package/project/.sdk/tm/java/test/FeatureTest.java +25 -0
- package/project/.sdk/tm/java/test/PrimaryUtilityTest.java +39 -0
- package/project/.sdk/tm/java/test/feature/secrets/SecretsFeatureTest.java +267 -53
- package/project/.sdk/tm/java/utility/Fetcher.java +18 -2
- package/project/.sdk/tm/java/utility/Media.java +2 -2
- package/project/.sdk/tm/js/src/feature/cache/CacheFeature.js +13 -0
- package/project/.sdk/tm/js/src/feature/secrets/SecretsFeature.js +79 -29
- package/project/.sdk/tm/js/test/feature/secrets/Secrets.test.js +282 -93
- package/project/.sdk/tm/js/test/feature.test.js +17 -0
- package/project/.sdk/tm/kotlin/core/Control.kt +0 -5
- package/project/.sdk/tm/kotlin/feature/CacheFeature.kt +12 -0
- package/project/.sdk/tm/kotlin/feature/SecretsFeature.kt +84 -24
- package/project/.sdk/tm/kotlin/test/FeatureTest.kt +24 -0
- package/project/.sdk/tm/kotlin/test/PrimaryUtilityTest.kt +35 -0
- package/project/.sdk/tm/kotlin/test/feature/secrets/SecretsTest.kt +236 -54
- package/project/.sdk/tm/kotlin/utility/Fetcher.kt +13 -1
- package/project/.sdk/tm/lua/feature/cache_feature.lua +20 -0
- package/project/.sdk/tm/lua/feature/secrets_feature.lua +92 -15
- package/project/.sdk/tm/lua/test/feature/secrets/secrets_feature_test.lua +208 -43
- package/project/.sdk/tm/lua/test/feature_test.lua +18 -0
- package/project/.sdk/tm/lua/utility/clean.lua +1 -0
- package/project/.sdk/tm/ocaml/feature/secrets_feature.ml +100 -14
- package/project/.sdk/tm/ocaml/sdk_features.ml +7 -1
- package/project/.sdk/tm/ocaml/test/feature/secrets/t_secrets.ml +143 -7
- package/project/.sdk/tm/ocaml/test/t_feature.ml +15 -0
- package/project/.sdk/tm/perl/feature/cache_feature.pm +13 -0
- package/project/.sdk/tm/perl/feature/secrets_feature.pm +87 -32
- package/project/.sdk/tm/perl/t/feature/secrets/secrets.t +177 -24
- package/project/.sdk/tm/perl/t/feature.t +24 -0
- package/project/.sdk/tm/php/feature/CacheFeature.php +13 -0
- package/project/.sdk/tm/php/feature/SecretsFeature.php +79 -23
- package/project/.sdk/tm/php/test/FeatureTest.php +23 -0
- package/project/.sdk/tm/php/test/feature/secrets/SecretsTest.php +258 -48
- package/project/.sdk/tm/py/pkg/feature/cache_feature.py +7 -1
- package/project/.sdk/tm/py/pkg/feature/secrets_feature.py +90 -29
- package/project/.sdk/tm/py/test/feature/secrets/test_secrets.py +313 -80
- package/project/.sdk/tm/py/test/test_feature.py +18 -0
- package/project/.sdk/tm/rb/feature/cache_feature.rb +12 -0
- package/project/.sdk/tm/rb/feature/secrets_feature.rb +68 -21
- package/project/.sdk/tm/rb/test/feature/secrets/secrets_feature_test.rb +214 -43
- package/project/.sdk/tm/rb/test/feature_test.rb +20 -0
- package/project/.sdk/tm/rust/feature/cache.rs +15 -1
- package/project/.sdk/tm/rust/feature/secrets.rs +103 -23
- package/project/.sdk/tm/rust/tests/feature/secrets/main.rs +357 -67
- package/project/.sdk/tm/rust/tests/feature_test.rs +41 -0
- package/project/.sdk/tm/scala/core/Control.scala +0 -5
- package/project/.sdk/tm/scala/feature/CacheFeature.scala +12 -0
- package/project/.sdk/tm/scala/feature/SecretsFeature.scala +88 -22
- package/project/.sdk/tm/scala/sdktest/SdkTestMain.scala +61 -1
- package/project/.sdk/tm/scala/sdktest/feature/secrets/SecretsTestMain.scala +230 -73
- package/project/.sdk/tm/scala/utility/Fetcher.scala +13 -1
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/core/Control.swift +0 -5
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/CacheFeature.swift +11 -0
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/feature/SecretsFeature.swift +76 -16
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/FeatureTest.swift +21 -0
- package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/feature/secrets/SecretsFeatureTest.swift +257 -73
- package/project/.sdk/tm/ts/src/feature/cache/CacheFeature.ts +13 -0
- package/project/.sdk/tm/ts/src/feature/secrets/SecretsFeature.ts +77 -17
- package/project/.sdk/tm/ts/test/feature/secrets/Secrets.test.ts +282 -87
- package/project/.sdk/tm/ts/test/feature.test.ts +17 -0
- package/project/.sdk/tm/zig/feature/cache.zig +15 -1
- package/project/.sdk/tm/zig/feature/secrets.zig +109 -32
- package/project/.sdk/tm/zig/test/feature/secrets/secrets_test.zig +232 -9
- package/project/.sdk/tm/zig/test/feature_test.zig +33 -0
- package/project/sdkgen-package.json +1 -1
|
@@ -100,6 +100,7 @@ typedef struct {
|
|
|
100
100
|
int64_t* statuses;
|
|
101
101
|
size_t nstatuses;
|
|
102
102
|
int64_t retries;
|
|
103
|
+
bool sameorigin;
|
|
103
104
|
} SecretsExchange;
|
|
104
105
|
|
|
105
106
|
typedef struct {
|
|
@@ -120,6 +121,11 @@ typedef struct {
|
|
|
120
121
|
// never written.
|
|
121
122
|
voxgig_value* liveopts;
|
|
122
123
|
|
|
124
|
+
// What prepare_auth was generated from: the config declares auth only
|
|
125
|
+
// where it places a credential, and Basic only where it composes one.
|
|
126
|
+
bool declared;
|
|
127
|
+
bool basic;
|
|
128
|
+
|
|
123
129
|
const char* secretname;
|
|
124
130
|
bool cache;
|
|
125
131
|
|
|
@@ -277,6 +283,13 @@ static bool spec_of_map(sek_pool* pool, voxgig_value* m, sek_spec* spec, const c
|
|
|
277
283
|
|
|
278
284
|
// ---- credential injection ---------------------------------------------------
|
|
279
285
|
|
|
286
|
+
// prepare_auth's decision: auth the config declares, not suppressed by
|
|
287
|
+
// `auth: null`.
|
|
288
|
+
static bool secrets_authon(SecretsFeature* f) {
|
|
289
|
+
voxgig_value* auth = getp(f->liveopts, "auth");
|
|
290
|
+
return f->declared && !v_is_noval(auth) && !v_is_null(auth);
|
|
291
|
+
}
|
|
292
|
+
|
|
280
293
|
// Write the resolved credential into THIS request's credential header,
|
|
281
294
|
// the way prepare_auth builds it (same options auth name and prefix, same
|
|
282
295
|
// suppression rule), so the two cannot drift.
|
|
@@ -303,7 +316,7 @@ static void secrets_reauth(SecretsFeature* f, voxgig_value* fetchdef) {
|
|
|
303
316
|
}
|
|
304
317
|
|
|
305
318
|
voxgig_value* auth = getp(f->liveopts, "auth");
|
|
306
|
-
if (
|
|
319
|
+
if (!secrets_authon(f)) {
|
|
307
320
|
voxgig_value* k = voxgig_new_string(name);
|
|
308
321
|
voxgig_delprop(headers, k);
|
|
309
322
|
voxgig_release(k);
|
|
@@ -316,16 +329,42 @@ static void secrets_reauth(SecretsFeature* f, voxgig_value* fetchdef) {
|
|
|
316
329
|
return;
|
|
317
330
|
}
|
|
318
331
|
|
|
332
|
+
// Under Basic the token is the key half, as apikey is: prepare_auth's pair.
|
|
333
|
+
bool want_basic = false;
|
|
334
|
+
if (f->basic) get_bool(auth, "basic", &want_basic);
|
|
335
|
+
char* value = NULL;
|
|
336
|
+
if (want_basic) {
|
|
337
|
+
const char* secret = get_str(f->liveopts, "secret");
|
|
338
|
+
if (NULL == secret) secret = "";
|
|
339
|
+
size_t n = strlen(f->cred) + 1 + strlen(secret) + 1;
|
|
340
|
+
char* pair = (char*)malloc(n);
|
|
341
|
+
if (NULL == pair) {
|
|
342
|
+
free(name);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
snprintf(pair, n, "%s:%s", f->cred, secret);
|
|
346
|
+
value = clean_base64(pair);
|
|
347
|
+
free(pair);
|
|
348
|
+
if (NULL != value) clean_add_opts(f->liveopts, value);
|
|
349
|
+
} else {
|
|
350
|
+
value = strdup(f->cred);
|
|
351
|
+
}
|
|
352
|
+
if (NULL == value) {
|
|
353
|
+
free(name);
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
|
|
319
357
|
const char* prefix = get_str(auth, "prefix");
|
|
320
358
|
if (NULL == prefix || '\0' == prefix[0]) {
|
|
321
|
-
setp(headers, name, v_str(
|
|
359
|
+
setp(headers, name, v_str(value));
|
|
322
360
|
} else {
|
|
323
|
-
size_t n = strlen(prefix) + 1 + strlen(
|
|
361
|
+
size_t n = strlen(prefix) + 1 + strlen(value) + 1;
|
|
324
362
|
char* buf = (char*)malloc(n);
|
|
325
|
-
snprintf(buf, n, "%s %s", prefix,
|
|
363
|
+
snprintf(buf, n, "%s %s", prefix, value);
|
|
326
364
|
setp(headers, name, v_str(buf));
|
|
327
365
|
free(buf);
|
|
328
366
|
}
|
|
367
|
+
free(value);
|
|
329
368
|
free(name);
|
|
330
369
|
}
|
|
331
370
|
|
|
@@ -341,6 +380,90 @@ static void secrets_setcred(SecretsFeature* f, const char* value) {
|
|
|
341
380
|
|
|
342
381
|
// ---- the exchange -----------------------------------------------------------
|
|
343
382
|
|
|
383
|
+
#define SECRETS_REDIRECT_MAX 5
|
|
384
|
+
|
|
385
|
+
// "scheme://host:port" of an absolute http(s) URL, the port defaulted; and,
|
|
386
|
+
// in *rest, where its authority ends. 0 when it is not one.
|
|
387
|
+
static int secrets_origin(const char* url, char* out, size_t size, const char** rest) {
|
|
388
|
+
const char* sep = strstr(url, "://");
|
|
389
|
+
size_t slen = NULL == sep ? 0 : (size_t)(sep - url);
|
|
390
|
+
char scheme[6] = "";
|
|
391
|
+
if (5 < slen) return 0;
|
|
392
|
+
for (size_t i = 0; i < slen; i++) {
|
|
393
|
+
scheme[i] = (char)('A' <= url[i] && url[i] <= 'Z' ? url[i] - 'A' + 'a' : url[i]);
|
|
394
|
+
}
|
|
395
|
+
int https = 0 == strcmp(scheme, "https");
|
|
396
|
+
if (!https && 0 != strcmp(scheme, "http")) return 0;
|
|
397
|
+
const char* auth = sep + 3;
|
|
398
|
+
const char* end = auth + strcspn(auth, "/?#");
|
|
399
|
+
for (const char* at = auth; at < end; at++) if ('@' == *at) auth = at + 1;
|
|
400
|
+
const char* colon = '[' == *auth ? memchr(auth, ']', (size_t)(end - auth)) : auth;
|
|
401
|
+
if (NULL == colon) return 0;
|
|
402
|
+
colon = memchr(colon, ':', (size_t)(end - colon));
|
|
403
|
+
const char* hostend = NULL == colon ? end : colon;
|
|
404
|
+
if (hostend == auth) return 0;
|
|
405
|
+
long port = https ? 443 : 80;
|
|
406
|
+
if (NULL != colon && colon + 1 < end) {
|
|
407
|
+
char* stop = NULL;
|
|
408
|
+
port = strtol(colon + 1, &stop, 10);
|
|
409
|
+
if (stop != end || port < 0 || 65535 < port) return 0;
|
|
410
|
+
}
|
|
411
|
+
int n = snprintf(out, size, "%s://%.*s:%ld", https ? "https" : "http",
|
|
412
|
+
(int)(hostend - auth), auth, port);
|
|
413
|
+
if (n < 0 || (size_t)n >= size) return 0;
|
|
414
|
+
for (char* c = out; '\0' != *c; c++) if ('A' <= *c && *c <= 'Z') *c = (char)(*c - 'A' + 'a');
|
|
415
|
+
if (NULL != rest) *rest = end;
|
|
416
|
+
return 1;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// Where a 307 or 308 points, when that is on the exchange's own origin. Any
|
|
420
|
+
// other redirect would drop the body or leave the origin.
|
|
421
|
+
static char* secrets_moved(sek_pool* pool, const char* url, const char* at, voxgig_value* res) {
|
|
422
|
+
int64_t status = to_int(getp(res, "status"));
|
|
423
|
+
const char* location = get_str(getp(res, "headers"), "location");
|
|
424
|
+
char own[320];
|
|
425
|
+
char from[320];
|
|
426
|
+
char to[320];
|
|
427
|
+
const char* rest = NULL;
|
|
428
|
+
if ((307 != status && 308 != status) || NULL == location || '\0' == location[0] ||
|
|
429
|
+
!secrets_origin(url, own, sizeof(own), NULL) ||
|
|
430
|
+
!secrets_origin(at, from, sizeof(from), &rest)) {
|
|
431
|
+
return NULL;
|
|
432
|
+
}
|
|
433
|
+
char* next;
|
|
434
|
+
if (NULL != strstr(location, "://")) {
|
|
435
|
+
next = sek_strdup(pool, location);
|
|
436
|
+
} else if ('/' == location[0] && '/' == location[1]) {
|
|
437
|
+
next = sek_fmt(pool, "%.*s:%s", (int)(strstr(at, "://") - at), at, location);
|
|
438
|
+
} else if ('/' == location[0]) {
|
|
439
|
+
next = sek_fmt(pool, "%.*s%s", (int)(rest - at), at, location);
|
|
440
|
+
} else if ('?' == location[0]) {
|
|
441
|
+
next = sek_fmt(pool, "%.*s%s", (int)strcspn(at, "?#"), at, location);
|
|
442
|
+
} else {
|
|
443
|
+
size_t dir = (size_t)(rest - at);
|
|
444
|
+
for (size_t i = dir; '\0' != at[i] && '?' != at[i] && '#' != at[i]; i++) {
|
|
445
|
+
if ('/' == at[i]) dir = i + 1;
|
|
446
|
+
}
|
|
447
|
+
next = sek_fmt(pool, "%.*s%s%s", (int)dir, at, dir == (size_t)(rest - at) ? "/" : "", location);
|
|
448
|
+
}
|
|
449
|
+
return secrets_origin(next, to, sizeof(to), NULL) && 0 == strcmp(own, to) ? next : NULL;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// One request of the exchange: options.system.fetch when supplied, else the
|
|
453
|
+
// transport of last resort. A pool-owned message on failure.
|
|
454
|
+
static const char* secrets_send(SecretsFeature* f, Context* ctx, voxgig_value* sys_fetch,
|
|
455
|
+
const char* url, voxgig_value* fetchdef, voxgig_value** res) {
|
|
456
|
+
if (voxgig_is_func(sys_fetch)) {
|
|
457
|
+
*res = call_vfn(sys_fetch, clist(2, v_str(url), v_share(fetchdef)));
|
|
458
|
+
const char* emsg = get_str(*res, "__err__");
|
|
459
|
+
return NULL == emsg ? NULL : sek_strdup(f->pool, emsg);
|
|
460
|
+
}
|
|
461
|
+
PNError* ferr = NULL;
|
|
462
|
+
*res = secrets_rawfetch(ctx, url, fetchdef, &ferr);
|
|
463
|
+
return NULL == ferr ? NULL :
|
|
464
|
+
sek_strdup(f->pool, ferr->msg ? ferr->msg : "secrets: transport failed");
|
|
465
|
+
}
|
|
466
|
+
|
|
344
467
|
// Buy an access token with the refresh token. Answers sekreto-style: a
|
|
345
468
|
// pool-owned message, or NULL for success with the token in f->cred.
|
|
346
469
|
static const char* secrets_buy(SecretsFeature* f, Context* ctx) {
|
|
@@ -402,15 +525,18 @@ static const char* secrets_buy(SecretsFeature* f, Context* ctx) {
|
|
|
402
525
|
// supplied one (the seam every live c request already uses), else the
|
|
403
526
|
// bundled transport of last resort from the generated kinds.c.
|
|
404
527
|
voxgig_value* sys_fetch = getpath2(options, "system", "fetch");
|
|
405
|
-
voxgig_value* res;
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
if (NULL
|
|
528
|
+
voxgig_value* res = NULL;
|
|
529
|
+
const char* sent = secrets_send(f, ctx, sys_fetch, url, fetchdef, &res);
|
|
530
|
+
if (NULL != sent) return sent;
|
|
531
|
+
|
|
532
|
+
// By option alone, and only while the exchange stays on its own origin.
|
|
533
|
+
const char* at = url;
|
|
534
|
+
for (int hops = 0; x->sameorigin && hops < SECRETS_REDIRECT_MAX; hops++) {
|
|
535
|
+
char* next = secrets_moved(f->pool, url, at, res);
|
|
536
|
+
if (NULL == next) break;
|
|
537
|
+
at = next;
|
|
538
|
+
sent = secrets_send(f, ctx, sys_fetch, at, fetchdef, &res);
|
|
539
|
+
if (NULL != sent) return sent;
|
|
414
540
|
}
|
|
415
541
|
|
|
416
542
|
int64_t status = to_int(getp(res, "status"));
|
|
@@ -458,7 +584,7 @@ static bool secrets_spent(SecretsFeature* f, voxgig_value* res) {
|
|
|
458
584
|
static const char* secrets_resolve(SecretsFeature* f, Context* ctx) {
|
|
459
585
|
if (NULL != f->initerr) return f->initerr;
|
|
460
586
|
if (f->cache && f->resolved) return NULL;
|
|
461
|
-
if (NULL == f->sek) return NULL;
|
|
587
|
+
if (NULL == f->sek || !secrets_authon(f)) return NULL;
|
|
462
588
|
|
|
463
589
|
char* found = NULL;
|
|
464
590
|
sek_err err = sek_try(f->sek, f->secretname, &found);
|
|
@@ -542,10 +668,9 @@ static voxgig_value* secrets_fetch(Fetcher* self, Context* ctx, const char* url,
|
|
|
542
668
|
return st->inner->fn(st->inner, ctx, url, fetchdef, err);
|
|
543
669
|
}
|
|
544
670
|
|
|
545
|
-
//
|
|
546
|
-
//
|
|
547
|
-
|
|
548
|
-
if (v_is_noval(auth) || v_is_null(auth)) {
|
|
671
|
+
// A refusal of an unauthenticated request is not an expired token, and
|
|
672
|
+
// retrying would transmit the credential that auth off withholds.
|
|
673
|
+
if (!secrets_authon(f)) {
|
|
549
674
|
return st->inner->fn(st->inner, ctx, url, fetchdef, err);
|
|
550
675
|
}
|
|
551
676
|
|
|
@@ -609,6 +734,11 @@ static void secrets_init(Feature* fb, Context* ctx, voxgig_value* options) {
|
|
|
609
734
|
f->client = ctx->client;
|
|
610
735
|
f->liveopts = ctx->options;
|
|
611
736
|
|
|
737
|
+
voxgig_value* declared = NULL == ctx->config ? NULL : getpath2(ctx->config, "options", "auth");
|
|
738
|
+
f->declared = voxgig_is_map(declared);
|
|
739
|
+
f->basic = false;
|
|
740
|
+
if (f->declared) get_bool(declared, "basic", &f->basic);
|
|
741
|
+
|
|
612
742
|
// WRAP FIRST. The fail-closed gate needs the seam whatever happens
|
|
613
743
|
// below - a chain that fails to build must still refuse to send - so the
|
|
614
744
|
// wrapper is installed before anything here can fail, and the exchange
|
|
@@ -638,6 +768,7 @@ static void secrets_init(Feature* fb, Context* ctx, voxgig_value* options) {
|
|
|
638
768
|
x->request = fopt_str(xopts, "request", "refresh_token");
|
|
639
769
|
x->response = fopt_str(xopts, "response", "access_token");
|
|
640
770
|
x->retries = fopt_int(xopts, "retries", 1);
|
|
771
|
+
x->sameorigin = 0 == strcmp("same-origin", fopt_str(xopts, "redirect", "refuse"));
|
|
641
772
|
voxgig_value* sl = fopt_list(xopts, "statuses");
|
|
642
773
|
if (voxgig_is_list(sl) && 0 < voxgig_as_list(sl)->len) {
|
|
643
774
|
voxgig_list* l = voxgig_as_list(sl);
|