Repository navigation
Ariadne credentials: several per reply, form and header values, --credential-env (cypkg) - #895
Merged
Merged
Conversation
…r values, --credential-env cypkg (cy-pca/cypkg), a terminal client for cvcpkg registries written as .ari documents, signs in with cvcpkg's device pairing. Its token reply carries an access and a refresh token, a refresh is an RFC 6749 section 6 form POST, and CI uses an API token from the environment. #888's credentials covered one token per reply, sent as a Bearer header; these three generic additions cover the rest without a token ever reaching the document (#888 (comment)). - capture_auth takes a list of {name, field, optional} dicts, one credential each, all captured from the URL's origin. Every field is taken first and each token blanked wherever the reply carries it, then each is kept. A missing optional field is no error: a refresh reply need not rotate the refresh token. A name given twice is an error. captured is true when every required field was kept; error names the ones that were not. - A credential value, (dict "credential" NAME), as a form or headers dict value: the request is encoded with a random letters-and-digits placeholder in its place, and the host puts the token there as it is sent (percent-encoded in a form, as is in a header), only for an origin NAME is bound to, like auth; elsewhere the request is not sent. Echoes are blanked in both spellings. A query refuses one (URLs are logged). Any credential option turns off redirect following, and the origin is checked against the policy before any token is looked up. - --credential-env NAME=VAR (repeatable, implies --net, native only): enable_net holds the token in VAR as credential NAME for the run, through the new CredentialStore::provide: in memory, ahead of the file's token for NAME, never written, replaced by a capture. A policy credential line must bind NAME, so the launcher decides where it goes. An unset or empty VAR supplies nothing, so a launcher can always pass the flag; a malformed value stops the host without being quoted. ari/arigl info list the names it supplied. - ari and arigl --help, net_intrinsics.h and docs/ARIADNE.md 10.2 and 10.3 describe them. Tests: - net_policy_test: provide (bound names only, ahead of the file, never written, replaced by a capture, forgotten). - ariadne_host_test: --credential-env parsing and its errors. - ariadne_runtime_test, against a localhost registry: a device reply gives two credentials and a refresh with a form credential sends the refresh token (percent-encoded) and keeps the new access token, no token in the state tree; credential values only for bound origins, never in a query, a duplicate capture name refused; an environment token as a Bearer and as an X-Api-Key header, never in the store file, an unbound name and a malformed value refused, an unset variable harmless. - ari_net_test: the same device sign-in and refresh, and --credential-env, through the built ari, no output carrying a token.
Nothing tested a request from the single-threaded browser build, where the verbs run inline and the fetch backend spins on emscripten_sleep. The "ari terminal backend (wasm, node)" job now does: - src/ari/tests/net_probe.ari signs in (two tokens from one reply), refreshes with the refresh token as a form credential, fetches with the refreshed token, and is refused another origin; net_probe_server.py stands in for the registry. - xhr-shim.cjs: a small XMLHttpRequest over node's fetch, enough for emscripten's Fetch.js, so the page's cvc::net fetch backend runs under node (which has fetch but no XMLHttpRequest). - CVC_ARI_WASM_TEST_DOCS (off by default) embeds src/ari/tests at /tests in the wasm ari; the job turns it on, runs the probe, checks the results and that no token reached the output. - The job also runs when src/cvc/net or inc/cvc/net change. Run locally with the cvcpkg emsdk 5.0.7: every check passes.
transfix
enabled auto-merge (squash)
October 30, 2026 05:46
From nicotina M0's notes on #888: - arigl snapshot (window and --terminal) did not wait for requests as ari snapshot does, so one frame showed a document's first frame; nicotina's tests passed --frames 60 instead. - ari's wait ended after three drains with no async call in flight. A program working between two requests (parsing a reply is a sliced data step, not an async call) looked idle then, and the snapshot could miss the second reply. AppRuntime::idle() is now "no async call in flight and no program step waiting to run" (async_scheduler::has_runnable), and AppRuntime::settle(step, max_seconds) runs a host's step until the document has been idle for three steps running, at most 10 s. ari snapshot, arigl's terminal snapshot (a drain) and its window snapshot (a whole frame, the PNG written after) call it when the network is on. - ari_net_test SnapshotWaitsThroughWorkBetweenRequests: a document that loops between two requests shows both replies in a one-frame snapshot. With idle() back at "no call in flight" it fails (the second is empty); the whole suite still runs in about 3 s. - arigl is built only through the wasm-mt tree here (no native VTK); it compiles and links. CI's cvcGL lanes build it natively. - ari and arigl --help and docs/ARIADNE.md 10.3 say so.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A follow-up to #888 (merged as 276887d), on master.
These are three generic additions to Ariadne's host-owned credentials that cypkg (cy-pca/cypkg, a terminal client for cvcpkg registries written as
.aridocuments) needs for cvcpkg's device sign-in. The asks are in #888 (comment). With them, a document signs in, refreshes and uses an API token without ever holding a token.What it adds
1. Several credentials from one reply.
capture_authalso takes a list:"optional" #tfield may be missing, since a refresh reply need not rotate the refresh token.2. A stored credential as a form or header value. Writing
(dict "credential" NAME)as aformorheadersdict value makes the host fill in the token at send time:X-Api-Key, say);auth:; elsewhere the request isn't sent;queryrefuses one, since URLs are logged.So an RFC 6749 §6 refresh shows the document neither token:
3.
--credential-env NAME=VAR. This is for API tokens and CI (cvcpkg'sCVCPKG_TOKEN). It is repeatable, native only, and implies--net.credential NAME ORIGIN...line must bind NAME, so the launcher, not the document, decides where the token may go.ari infoandarigl infolist the names it supplied.The browser path, now in CI
Nothing tested a request from the single-threaded wasm
ari, where the verbs run inline and the fetch backend spins onemscripten_sleep. The "ari terminal backend (wasm, node)" job now runssrc/ari/tests/net_probe.ariagainstnet_probe_server.pyunder node. It covers a device sign-in with two tokens, a refresh with a form credential, a fetch with the refreshed token, and a refused origin, and it fails if any token reaches the output.xhr-shim.cjsis a smallXMLHttpRequestover node'sfetch, enough for emscripten's Fetch.js. The probe is embedded only with-DCVC_ARI_WASM_TEST_DOCS=ON, so the published page doesn't carry it. The job now also runs whensrc/cvc/netchanges. The shim exercises the page's own cvc::net code and verbs, but not a browser's CORS.Snapshots wait until the document is idle (from nicotina M0's notes)
arigl snapshot, in a window and with--terminal, now waits likeari snapshot. Before, one frame showed a document's first frame, and nicotina's tests passed--frames 60to work around it.AppRuntime::idle()now means no async call in flight and no program step waiting to run.AppRuntime::settle(step, max_seconds)runs the host's step until the document has been idle for three steps running, at most 10 s.ari snapshotand both ofarigl snapshot's paths use it whenever the network is on.ari_net_testcase loops between two requests and fails with the old check; the whole suite still runs in about 3 s.ariglbuilds here only through the wasm-mt tree (no native VTK), where it compiles and links. CI's cvcGL lanes build it natively.Tests
net_policy_test:CredentialStore::provide. It works only for bound names, sits ahead of the file's token, is never written, and gives way to a capture.ariadne_host_test:--credential-envparsing and its errors.ariadne_runtime_test, against a localhost registry:%2Fchecked) and keeps the new access token;X-Api-Keyheader, and is never in the store file;ari_net_test: the same device sign-in, refresh and--credential-env, through the builtari, with no output carrying a token.Local results, rebased on master 276887d (Linux RelWithDebInfo):
net_policy_test23/23,ariadne_host_test21/21,ariadne_runtime_test203 passed (one unrelated locale skip),ari_net_test8/8,state_exec_async_calls_test47/47;ariadne_loader_test,uri_http_cache_testandnet_http_client_testpass unchanged;