Skip to content

relay joins: token: oidc (a host credential) and reconnects - #1132

Merged
transfix merged 2 commits into
feat/arisrvx-authenticatefrom
feat/relay-join-oidc
Nov 10, 2026
Merged

transfix merged 2 commits into
feat/arisrvx-authenticatefrom
feat/relay-join-oidc

Conversation

@transfix

Copy link
Copy Markdown
Owner

The client half that S2 and S5 left out (docs/roadmap/ARIADNE_SCRIPTING_HOSTS.md §6.5.7): relay: token: oidc and reconnects. Stacked on #1130 (S5), which is on #1122 (S2): its base is feat/arisrvx-authenticate.

What it adds

relay:
  url: grpcs://ops.example.com:7700
  token: oidc:ops-sso          # the credential (oidc-sign-in ...) keeps; or credential:NAME
  subscribe: [cyprov]
# the launcher's policy: the credential may go to the relay
allow https://ops.example.com:7700
credential ops-sso https://ops.example.com:7700
  • The token's forms. token: credential:NAME, oidc:NAME, or --relay-credential NAME.
    • At every join the token comes from the host's credential store (net_host_access) for the relay's origin (relay_credential_origin: https://host:port for grpcs:// and wss://, http:// for grpc:// and ws://). CredentialStore::token_for releases a token only where it is bound, hence the policy line.
    • A credential the relay refused, or that its renewer says is expiring, is renewed before the dial, which an OIDC sign-in does with its refresh token.
    • A bare token: oidc is refused with a pointer to oidc:NAME, since a sign-in's credential has no default name.
  • A join that waits for the sign-in.
    • With a credential, attach_relay begins the session (relay_session::begin) instead of joining at load.
    • pump() dials once the credential holds a token. The dial runs on a thread of its own, so a frame never waits on the network or a refresh.
    • Until then room-call answers unavailable.
  • Reconnects, for every join.
    • A link the relay closes (a restart, host.disconnect, a network drop) is dialed again after 1 s, doubling to 30 s, with the token read again.
    • The shard and the participant id are kept, so S5's same-principal rule hands the participant back.
    • A dial counts once the relay's Hello arrives. Replies write through the admission hold, so it does not wait for the room's tree again.
  • The document sees it. relay.status (joined, dialing, waiting for credential NAME (…), lost; dialing again (…)) and relay.joins under its root.
  • A deflaked S1 test. arisrvx_program waited for job.state and could read steps half written, since the relay writes a subtree leaf by leaf. It failed once here under -j 3. It waits for the last leaf now.

Tests

  • Unit: RoomRelayLoopbackTest.ARelaySessionJoinsOnceItsCredentialHoldsAToken:
    • no token: no join, no room-call client, and the status says it is waiting;
    • then the token arrives and it joins;
    • relay_credential_origin's mapping.
  • Unit: RoomRelayLoopbackTest.ARelaySessionRenewsARefusedCredential: a relay with a room token refuses the first token; the redial, after the backoff, hands it back as rejected, and the fresh token joins.
  • ctest: arisrvx_auth_credential. ari test --relay-credential relaytok gets its token through --credential-env, bound to the relay's origin by a policy line relay_pair.py writes. The hook admits it as alice. host.disconnect closes the connection, the client dials again, and the hook admits it a second time (relay.joins 2).
  • ctest: arisrvx_auth_staff now revokes instead of kicking: the hook refuses alice afterwards, so her client's redials are refused and her calls stay unavailable. With reconnects, a kick alone would let her straight back.

Run locally on Windows (static Release, gRPC + WS, pycvc core, wasmtime from cvcpkg):

  • the S2 + S5 + this ctest set: 51/51 with -j 3;
  • room_relay_integration_test: 21/21;
  • ariadne_host_test: 57/57.

Not in this PR

  • A real OIDC provider in CI. The ctest supplies the credential through --credential-env (the store's provide); the sign-in itself is oidc_host.h's, tested there.
  • Native wss://.
  • No release.

The client half S2 and S5 left out (docs/roadmap/ARIADNE_SCRIPTING_HOSTS.md
6.5.7), stacked on S5.

relay: token: credential:NAME, or oidc:NAME for the credential an
(oidc-sign-in ...) keeps, and --relay-credential NAME: the token is read
from the host's credential store (net_host_access) at every join, for
the relay's origin (relay_credential_origin: https://host:port for
grpcs:// and wss://, http:// for grpc:// and ws://), which a policy line
binds the credential to. A credential the relay refused, or that its
renewer says is expiring, is renewed first: an OIDC sign-in refreshes it.

The join waits for the credential: attach_relay begins the session, and
pump() dials from the frames once the credential holds a token, on a
thread of its own so a frame never waits on the network. Until then
room-call answers unavailable.

Every join reconnects: a link the relay closes is dialed again after 1 s,
doubling to 30 s, with the token read again, the shard and the
participant id kept. A dial counts once the relay's Hello arrives
(replies write through the admission hold). The document sees
relay.status and relay.joins under its root.

S1's arisrvx_program waited for job.state and could read steps half
written (the relay writes a subtree leaf by leaf); it waits for the last
leaf now.

Tests: RoomRelayLoopbackTest.ARelaySessionJoinsOnceItsCredentialHoldsAToken,
RoomRelayLoopbackTest.ARelaySessionRenewsARefusedCredential,
arisrvx_auth_credential (a credential through --credential-env and a
policy line; host.disconnect, then the client is back and admitted
again), and arisrvx_auth_staff now revokes (the hook refuses, so the
client stays out).
@transfix
transfix merged commit d444453 into feat/arisrvx-authenticate Nov 10, 2026
6 checks passed
@transfix
transfix deleted the feat/relay-join-oidc branch November 10, 2026 20:24
transfix added a commit that referenced this pull request Nov 11, 2026
…th token: oidc (#1130)

* arisrvx: the authenticate hook and principals (S5)

S5 of the scripting-hosts roadmap's application-services cut
(docs/roadmap/ARIADNE_SCRIPTING_HOSTS.md 6.5.4 and the S5 row of 10),
stacked on S2.

Transports: state_transport::set_authenticator takes a state_authenticator
(a state_credential of bearer, transport and peer, mapped to a principal
id, or "" and why). gRPC calls it in Channel(), WS during the upgrade, on
the connection's own thread before it is admitted, in place of the room
token; a refusal is the room token's (UNAUTHENTICATED, a refused upgrade),
with nothing sent. disconnect_principal closes a principal's connections.
valid_bearer_token allows bearers up to 4096 characters, so a JWT fits.

The gate: state_inbound_gate::bind takes the claimant's principal; a
silent holder's id is taken over only by the same principal
(total_principal_refusals), and principal_of names whose a participant is.

arisrvx: @host.authenticate (sync or async; a principal dict with a str id,
or None) runs on the script loop for each connection, within
--auth-timeout (5 s; ServerLink::request waits). The relay keeps each
principal by id for its calls' ctx.principal, so role gates check its
roles. host.disconnect(principal) closes that principal's connections on
the next room step. Calls are limited per principal: --call-concurrency
(8 in flight) and --call-rate (a token bucket, off by default), past which
a call is answered rate_limited.

Clients: a refused join fails at once ("refused this host
(unauthenticated...)"), and a connection the relay closes later ends the
waiting and later calls unavailable.

Not here: the client's token: oidc, which needs a join deferred until the
sign-in and a reconnect that refreshes the token.

Tests: StateTransportGrpcTest.InboundGateKeysANodeIdToItsPrincipal,
StateTransportGrpcTest.AnAuthenticatorAdmitsAndBindsPrincipals,
StateTransportWsTest.AnAuthenticatorJudgesTheHandshake,
ServerLinkTest.ARequestWaitsForItsAnswerOrItsTimeout, pycvc_ariadne_server,
and arisrvx_auth_{staff,user_ws,refuses_wrong,refuses_slow,refuses_raises}.

* docs(roadmap): S5 is #1130

* relay joins: token: oidc (a host credential) and reconnects (#1132)

* relay joins: token: oidc (a host credential) and reconnects

The client half S2 and S5 left out (docs/roadmap/ARIADNE_SCRIPTING_HOSTS.md
6.5.7), stacked on S5.

relay: token: credential:NAME, or oidc:NAME for the credential an
(oidc-sign-in ...) keeps, and --relay-credential NAME: the token is read
from the host's credential store (net_host_access) at every join, for
the relay's origin (relay_credential_origin: https://host:port for
grpcs:// and wss://, http:// for grpc:// and ws://), which a policy line
binds the credential to. A credential the relay refused, or that its
renewer says is expiring, is renewed first: an OIDC sign-in refreshes it.

The join waits for the credential: attach_relay begins the session, and
pump() dials from the frames once the credential holds a token, on a
thread of its own so a frame never waits on the network. Until then
room-call answers unavailable.

Every join reconnects: a link the relay closes is dialed again after 1 s,
doubling to 30 s, with the token read again, the shard and the
participant id kept. A dial counts once the relay's Hello arrives
(replies write through the admission hold). The document sees
relay.status and relay.joins under its root.

S1's arisrvx_program waited for job.state and could read steps half
written (the relay writes a subtree leaf by leaf); it waits for the last
leaf now.

Tests: RoomRelayLoopbackTest.ARelaySessionJoinsOnceItsCredentialHoldsAToken,
RoomRelayLoopbackTest.ARelaySessionRenewsARefusedCredential,
arisrvx_auth_credential (a credential through --credential-env and a
policy line; host.disconnect, then the client is back and admitted
again), and arisrvx_auth_staff now revokes (the hook refuses, so the
client stays out).

* docs(roadmap): the client join is #1132
* arisrv: the browser build compiles S5's disconnect and the oidc dialer

CI's arigl-web job (emscripten, no pthreads) failed on
state_transport_ws::disconnect_principal: a browser connection has no
abort_io(). A browser accepts no connections, so none has a principal: the
browser build returns 0.

relay_session's dialer thread would throw there (std::thread in a
single-threaded build), so that build dials in the frame, as a token join's
dial does at the load.
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