Skip to content

Ariadne: sign in with any OpenID Connect provider (oidc-sign-in, open-url; nicotina L7, L9) - #916

Merged
transfix merged 11 commits into
masterfrom
feat/ariadne-oidc
Oct 31, 2026
Merged

transfix merged 11 commits into
masterfrom
feat/ariadne-oidc

Conversation

@transfix

@transfix transfix commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Items L7 (OIDC sign-in) and L9 (open-url) of nicotina's roadmap (cy-pca/nicotina docs/ROADMAP.md), built generic. Any Ariadne document can sign in with any standards-compliant OpenID Connect provider (Keycloak, Authentik, Google, a txwtf instance, ...) from the provider's issuer URL and a public client's id. It then names the credential on its requests with auth:, as with #888's credentials. Nothing in libcvc is specific to nicotina or txwtf.

Builds on #888 and #895 (net policy, credential store) and #887 (rebased onto it).

What a document does

(oidc-sign-in (dict "issuer" "https://id.example/realms/demo" "client_id" "my-app"
                    "scopes" (list "openid" "profile" "email") "credential" "me"))
;; progress and claims under oidc.me.* (phase, user_code, verification_uri, claims.name, ...),
;; the end on channel oidc#me; then:
(http-get "https://api.example/v1/me" (dict "auth" "me"))

The other verbs are oidc-cancel, oidc-sign-out (revocation per RFC 7009, optional RP-initiated logout), oidc-status and open-url. Gate a document on them with requires: / has?, using the tokens oidc, oidc.loopback, oidc.device, oidc.redirect and browser.

Per host (flow: auto)

host flow
ari (FTXUI, tvision), arigl --terminal, arigl in a window, with a desktop loopback (RFC 8252): listens on 127.0.0.1 on an ephemeral port, opens the system browser, takes one redirect, then shows "you can close this tab"
the same over SSH, with no display, or with --no-browser device (RFC 8628): the code and URL go to the document; polls honour interval, slow_down, access_denied and expired_token
arigl-web page, ari.html page redirect: the page goes to the provider and back. The PKCE verifier, state and nonce wait in sessionStorage, the code is exchanged on return, and history.replaceState takes code/state out of the address bar

The authorization code flows always use PKCE S256, state and nonce, and check RFC 9207 iss when the provider sends it. A flow the provider or the host cannot run fails clearly; for example, a provider without device_authorization_endpoint gets unsupported_flow.

Policy and tokens

  • Discovery fails closed:

    • the issuer must match exactly and pass the net policy;
    • endpoints must be https (http only for a loopback issuer);
    • endpoints must be at the issuer's origin, unless an oidc ISSUER ORIGIN... policy line lists another origin;
    • the provider must not rule out S256.
  • Launchers pin issuers and supply client ids with --oidc-issuer, --oidc-client ISSUER=ID, oidc / oidc-client policy lines, and the pages' ariadne.config.json flags.

  • Where the tokens live (none in the state tree, which state_transport_ws replicates, nor in logs or errors):

    credential holds bound to
    NAME the access token the issuer's origin, plus any origins a policy credential line binds NAME to
    NAME.refresh the refresh token the token endpoint's origin
    NAME.id the ID token
  • Refresh happens before expiry (also while idle) and once after a 401; the request is then re-sent. This uses the new generic CredentialRenewer hook in CredentialStore, consulted by auth: requests.

  • A sign-in kept in a --credential-store file is picked up again by oidc-sign-in with "interactive" #f.

  • ID tokens: iss, aud/azp, exp, iat and nonce are checked, and alg: none is refused. Signatures are not checked against the JWKS. ID tokens come only from the token endpoint over TLS (OIDC Core 3.1.3.7 (6)), and libcvc has RSA/EC crypto only optionally (OpenSSL, absent from the browser builds). Documented in ARIADNE.md 10.5 and 11.

  • open-url opens only http(s) URLs whose origin the host allows, so it cannot bypass the allowlist. It uses $BROWSER, xdg-open, open or ShellExecute natively and window.open in a page, at most one URL a second. With no browser the host prints the URL, except under a full-screen TUI, where the document shows it.

What a provider must allow (generic; for the txwtf provider session too)

  • A public client: the authorization code grant with PKCE S256 and no secret. An optional client_secret option exists for providers that hand installed apps a non-confidential secret (Google desktop clients).
  • The device grant, for SSH terminals.
  • A loopback redirect URI, http://127.0.0.1/callback, accepting any port (RFC 8252 7.3).
  • For the browser pages:
    • the page's URL as a redirect URI, exactly (with its query, or pin the page's document with src_param: false);
    • CORS for the page's origin on the discovery document and the token, device and revocation endpoints;
    • the page's CSP connect-src must include the provider's origin.
  • Refresh tokens if sessions should outlive the access token (some providers need offline_access).

Tests

All pass locally on Linux (native Release with tvision; wasm single-threaded, emsdk 5.0.7):

  • net_oidc_test (10): the protocol pieces, the loopback listener and open_url.

  • ariadne_runtime_test AriadneOidc.* (12), against a stub OP:

    • flows: loopback with a fake browser; device (approve, slow_down, deny); a browser-page redirect there and back (via the new cvc::net::page test hooks);
    • failures: forged state, replayed nonce, issuer pins and policy, a provider with no device endpoint;
    • token lifecycle: refresh before expiry and after a 401, sign-out with revocation and logout, resume across runs and the provider ending the session, the launcher's client id;
    • open-url against the policy;
    • no issued secret in the state tree.
  • ari_net_test AriOidc.* (4): the built ari (FTXUI and tvision) through a $BROWSER fake browser, a device code without one, resume across runs (0600 store), and bad flags.

  • ari_oidc_hosts (tmux, src/ari/tests/oidc_hosts_test.sh): ari run (FTXUI, tvision) and arigl run --terminal, each through the device and loopback flows, plus arigl's window snapshot. Every screen, stdout and stderr is checked against all 28 tokens, codes and device codes the stub issued. It skips without tmux (ci: tmux from cvcpkg on the Linux lanes, so the ari tmux tests run #901 adds tmux to CI).

  • wasm ari under node (new CI step, src/ari/tests/oidc_wasm_node_test.sh): with page-shim.cjs standing in for location, sessionStorage and history, the redirect flow goes there and back (code exchanged, address bar cleaned, API called with the credential), and the device code is shown. The existing net probe still passes.

  • Real browser, arigl-web + ari page: stock browser hosts that run .ari documents by URL; arigl and arigl-web packages #887's ari.html: built from this branch and served on 127.0.0.1 under arigl-web + ari page: stock browser hosts that run .ari documents by URL; arigl and arigl-web packages #887's strict CSP, with connect-src listing the stub provider. The page config carried --oidc-issuer and the probe's args. Opened in the desktop app's Chromium-based browser pane, the document:

    • signed in through the redirect flow: the page went to the provider and came back with code, state and iss (both loads are in the server log);
    • shows phase: signed_in, flow: redirect, the claims and api: 200;
    • left the address bar back at ?src=oidc_probe.ari and sessionStorage empty;
    • raised no CSP violation.

    arigl-web (the GL page) was not built locally; its sign-in code is the same libcvc.

  • Regression: ctest -R "Ariadne|ari|Ari|Net|net_|ImGui|arigl" 706/706 before the rebase onto arigl-web + ari page: stock browser hosts that run .ari documents by URL; arigl and arigl-web packages #887. After it, the OIDC, net, host-CLI and arigl-web + ari page: stock browser hosts that run .ari documents by URL; arigl and arigl-web packages #887 docset suites pass (69/69), as does the wasm check.

Not in this PR (follow-ups)

Example

examples/ariadne/documents/oidc_sign_in.ari:

ari run --oidc-issuer https://id.example/realms/demo examples/ariadne/documents/oidc_sign_in.ari \
    --issuer https://id.example/realms/demo --client my-app --api https://api.example/v1/me

src/ari/tests/stub_oidc_provider.py is a stdlib stub provider for trying a document by hand.

Docs: ARIADNE.md 10.5 (sign-in) and 10.6 (open-url), after #883's 10.4 (JSON replies); the 10.3 flag table, and a caveat in 11.

nicotina-ci added 7 commits October 30, 2026 17:24
…-url)

Items L7 and L9 of nicotina's roadmap (cy-pca/nicotina docs/ROADMAP.md): a generic OAuth 2.0 /
OpenID Connect client for every Ariadne host, so a document signs in through a provider (Keycloak,
Authentik, Google, a txwtf instance, ...) from its issuer URL and a public client's id, and then
names the credential on its requests with auth:. Nothing in libcvc is specific to a provider.

cvc::net (no Ariadne):
- oidc.h: discovery (fails closed: the issuer must match exactly, endpoints https, or http for a
  loopback issuer, at the issuer's origin or one the policy lists for it, PKCE S256 not ruled out),
  PKCE S256 from a CSPRNG, the authorization request and its reply (state, RFC 9207 iss, errors),
  token and device-authorization replies (RFC 6749 5.1/5.2, RFC 8628), ID token checks (iss, aud
  and azp, exp, iat, nonce; a refresh keeps sub; alg none refused). Signatures are not checked
  against the JWKS: ID tokens come only from the token endpoint over TLS (OIDC Core 3.1.3.7 (6)),
  and RSA/EC verification is not in every libcvc build. A small private JSON reader (json_lite).
- loopback_redirect.h: RFC 8252's listener, 127.0.0.1 only, an ephemeral port, one redirect, a
  404 for anything else, a "you can close this tab" page. Native only.
- browser.h: open_url ($BROWSER, xdg-open, open, ShellExecute, quiet; window.open in a page;
  no browser over SSH, without a display or with --no-browser) and the page a browser build runs
  in (its URL, sessionStorage, location.assign, history.replaceState), with test hooks.
- net_policy: oidc ISSUER [ORIGIN...] and oidc-client ISSUER ID lines; naming an issuer pins
  sign-in to the issuers named and allows their origins.
- credentials: a CredentialRenewer per credential. A request with auth: renews an expiring token
  first, and once more after a 401, then sends again.

Ariadne (oidc_host.h):
- (oidc-sign-in OPTS), (oidc-cancel NAME), (oidc-sign-out NAME [OPTS]), (oidc-status NAME) and
  (open-url URL). Runtime::drain advances the flows (pump_oidc); their requests run on the app's
  background pool, inline in a browser build without threads.
- flow auto|loopback|redirect|device: loopback with a browser natively, device with a code over
  SSH or with no browser, redirect in a browser page (the PKCE verifier, state and nonce wait in
  sessionStorage; on return the code is exchanged and code/state leave the address bar).
- Progress and the non-secret claims (sub, iss, name, email, preferred_username, exp) go to the
  state tree under oidc.<credential> (or a path the document picks), the end of a sign-in to the
  channel oidc#<credential>. Tokens stay in the credential store: NAME (bound to the issuer's
  origin and any the policy binds NAME to), NAME.refresh (the token endpoint's), NAME.id.
- Refresh before expiry (while idle, and before a request) and after a 401; a kept sign-in
  (--credential-store) resumes with "interactive" #f; sign-out revokes (RFC 7009) and can end the
  provider's session (RP-initiated logout).
- Host flags --oidc-issuer, --oidc-client ISSUER=ID, --oidc-redirect-uri and --no-browser, in ari
  and arigl alike and in the pages' config flags; ari/arigl info show them. Capability tokens
  oidc, oidc.loopback, oidc.device, oidc.redirect and browser.
- open-url opens only an http(s) URL whose origin the host allows, one a second; where there is no
  browser the host prints it, except while a full-screen terminal UI owns the screen.
- AppRuntime::idle counts a sign-in's request in flight, and a browser it opened, so a snapshot
  shows the end of a sign-in.

Tests: net_oidc_test (10: issuers, discovery, PKCE's RFC 7636 vector, the authorization request and
reply, token and device replies, ID token checks, policy lines, the loopback listener, open_url);
ariadne_runtime_test AriadneOidc.* (12) against a stub provider (stub_oidc_provider.h): loopback
with a fake browser, device (slow_down, a denial), a redirect from a browser page and back, a
forged state and a replayed nonce, the policy's pins and endpoint origins, a provider without
the device flow, refresh before expiry and after a 401, sign-out with revocation and logout, a kept
session resumed and ended by the provider, the launcher's client id, open-url and the policy; no
token the provider issued reaches the state tree. ariadne_host_test: the flags.
… and the wasm check

- ari_net_test AriOidc.* (4): the built ari signs in through a browser (tests/fake_browser.py as
  $BROWSER) with FTXUI and tvision, shows a device code without one, resumes a kept sign-in in the
  next run (0600 store), and refuses bad sign-in flags; no output carries a token.
- ari_oidc_hosts (tests/oidc_hosts_test.sh): ari run (FTXUI, tvision) and arigl run --terminal in
  tmux, each with a device code approved through the stub and through the loopback redirect, and
  arigl's window snapshot; every screen, stdout and stderr is checked for the provider's tokens,
  codes and device codes. Skipped without tmux or python3.
- tests/stub_oidc_provider.py: a standard-library stub provider (discovery, authorize, token,
  device, approve, revoke, logout, an API; CORS) for those tests, the wasm check and trying a
  document by hand. tests/oidc_probe.ari signs in, waits on oidc#me and calls the API.
- ci.yml, "ari terminal backend (wasm, node)": tests/oidc_wasm_node_test.sh runs the wasm ari under
  node with page-shim.cjs standing in for the page: the redirect flow there and back (code
  exchanged, address bar cleaned, the API called) and the device code; no token in the output.
- examples/ariadne/documents/oidc_sign_in.ari: sign in to a provider named on the command line
  and show the claims.
- docs/ARIADNE.md: 10.4 (sign-in: the verbs and options, the state keys, the flows per host, the
  tokens, the issuer policy, what a provider must allow) and 10.5 (open-url); the 10.3 flag
  table; a caveat in 11.
# Conflicts:
#	src/cvc/CMakeLists.txt
#	src/cvc/tests/CMakeLists.txt
#	src/cvc/tests/ariadne_runtime_test.cpp
# Conflicts:
#	src/ari/CMakeLists.txt
#	src/ari/ari_net_test.cpp
#	src/cvc/ariadne/host_cli.cpp
Joe Rivera and others added 3 commits October 31, 2026 01:17
# Conflicts:
#	.github/workflows/ci.yml
#	src/ari/CMakeLists.txt
#	src/cvc/ariadne/app_runtime.cpp
#	src/cvc/ariadne/net_intrinsics.cpp
# Conflicts:
#	src/ari/main.cpp
#	src/cvc/ariadne/host_cli.cpp
#	src/cvc/tests/ariadne_runtime_test.cpp
@transfix
transfix enabled auto-merge (squash) October 31, 2026 17:48
@transfix
transfix merged commit 78772e6 into master Oct 31, 2026
21 of 27 checks passed
@transfix
transfix deleted the feat/ariadne-oidc branch October 31, 2026 19:31
transfix pushed a commit to cy-pca/nicotina that referenced this pull request Oct 31, 2026
transfix/libcvc#916 (merged 19:31 UTC) gives ari open-url, so the documents show their In browser
button: on each feed card after Open, and on the post window in place of its URL. run.sh's
expectations were written for a host without it and failed six steps on libcvc master: the
card's counts row, the post's URL, and Load more, which Tab now reaches ten stops later.

run.sh asks the host (`ari check`, as for image.url and media.player) and expects either layout.
transfix added a commit to cy-pca/nicotina that referenced this pull request Oct 31, 2026
)

* Sign-in windows fit what they show; no status row without a message

transfix/libcvc#930 (merged 6d84dc7d) makes the tvision host refit a window that closes and
opens again, so the workaround for it goes: the sign-in, two-step and starting windows lose
their fixed 496 px width, and the status line takes a row only when the controller has a
message. The profile keeps its 76 columns, which is its layout, not the workaround.

tests/run.sh's tvision sign-out step ("Signed out." in the reopened sign-in form) is the check
that the refit works without the workaround.

* tests: a host with open-url adds In browser to each card and the post

transfix/libcvc#916 (merged 19:31 UTC) gives ari open-url, so the documents show their In browser
button: on each feed card after Open, and on the post window in place of its URL. run.sh's
expectations were written for a host without it and failed six steps on libcvc master: the
card's counts row, the post's URL, and Load more, which Tab now reaches ten stops later.

run.sh asks the host (`ari check`, as for image.url and media.player) and expects either layout.

---------

Co-authored-by: tfx <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant