Skip to content

feat(identitybroker): make the broker's lifetimes, clock skew, and timeouts settings - #2976

Merged
ChrisJBurns merged 1 commit into
mainfrom
feat/identitybroker-settings
Nov 24, 2026
Merged

ChrisJBurns merged 1 commit into
mainfrom
feat/identitybroker-settings

Conversation

@ChrisJBurns

Copy link
Copy Markdown
Contributor

Closes #2813.

Summary

The identity broker's lifetimes, clock skew, and request timeouts move from constants in code to optional settings in its configuration file (--identity-broker-config). Every setting has a documented default, bounds, and the risk it bounds. A file without the new fields loads with the same values as before, except for how long converted access-token jtis are remembered (see below).

Settings

"id_jag_max_lifetime": "12h",        // 1s–720h, whole seconds, ≥ 10 × clock_skew; hosted AS-1 only
"id_jag_lifetime": "60s",            // 1s–300s, whole seconds; hosted AS-1 only
"credential_lifetime": "1h",         // > 0, at most MaxCredentialLifetime (1h)
"client_assertion_lifetime": "60s",  // 1s–60s, whole seconds
"clock_skew": "30s",                 // 0s–60s
"as1_request_timeout": "10s",        // 1s–30s
"as2_request_timeout": "10s"         // 1s–1m
  • id_jag_max_lifetime: AS-1's maximum for grants that issue ID-JAGs, which is also every session's hard expiry. It stays separate from any schedule-horizon setting (Phase 2, Slice 3: Scheduled runs — A scheduled run calls gateway tools on its own grant, with no one present #2569).
  • id_jag_lifetime: applied to every gateway entry's ID-JAG target at AS-1. It also bounds the gateway token, which AS-2 caps at the ID-JAG's remaining validity. The gateway token's own lifetime stays with Bind each gateway token to its call #2727.
  • clock_skew: one setting replaces both the 30-second credential skew and the 5-minute converted-token retention. Its maximum is 60 seconds, because ToolHive accepts an actor credential's expiry only up to 60 seconds in the past; a larger skew would turn an expired credential into a server error instead of actor_token_expired, so the agent would never renew. The skew applies inside the broker only.
  • Timeouts: the AS-1 timeout is capped because it bounds how long session open holds the host session's open lock.

Startup refuses:

  • anything that isn't a Go duration string;
  • values out of bounds;
  • a skew above a tenth of id_jag_max_lifetime;
  • the id_jag_* values without a hosted AS-1.

Errors name the file.

Behaviour change

How long the broker remembers a converted access-token jti past its exp drops from 5 minutes to the clock skew (30 seconds by default). That is enough because AS-1 allows no leeway on an access token's exp. A new test against the real AS-1 pins that, so a ToolHive change that adds leeway fails it.

Other changes

  • AS-1's adapter now uses the core's bounds for the ID-JAG lifetimes, so there is one source of truth, and a target lifetime above 300 seconds is refused as invalid configuration.
  • The gateway-token marker in authorize.go now points only at Bind each gateway token to its call #2727. No #2813 markers remain.
  • The operator guide documents each setting.

Not in this PR

API compatibility

Assessment: no remote-observable API change. Only the broker's configuration file gains optional fields; the gRPC and HTTP APIs, session events, and model-visible tool results are unchanged. No major or feature change.

Testing

  • task lint: 0 issues.
  • go test -race over ./internal/... and ./cmd/...: pass. The root suite's only failures are deploy/helm/mecatl-execution and deploy/mecatl-execution-kind, which fail the same way on main.
  • task docs:check: pass.
  • New tests cover:
    • every bound, at the exact limit and just past it;
    • bad duration strings;
    • AS-1-only values without a hosted AS-1;
    • the skew rule.
  • They also cover the defaults, and each value reaching its consumer through app.Build:
    • the ID-JAG, credential and client-assertion lifetimes on the wire;
    • the session hard expiry, checked deterministically with an injected clock;
    • the skew in credential checks, credential pruning and converted-token memory;
    • both timeouts.

…meouts settings

The identity broker's configuration file takes optional id_jag_max_lifetime,
id_jag_lifetime, credential_lifetime, client_assertion_lifetime, clock_skew,
as1_request_timeout, and as2_request_timeout, each bounded and defaulting to
today's value. One clock skew, at most 60s, replaces both interim skews, so
converted access-token jtis are remembered for the skew past exp. Closes #2813.

Co-authored-by: Mecatl <[email protected]>

@rdimitrov rdimitrov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Checked:

  • Defaults match the old constants, except converted-token retention (5m → clock_skew). That is safe: golang-jwt treats a token as expired once now >= exp, so with no leeway at AS-1 a zero skew still covers it, and the new real-AS-1 test pins that.
  • The 60s MaxClockSkew reasoning holds: a larger skew would let the broker accept a credential that AS-1 then answers with a server error instead of actor_token_expired.
  • as2InProcessClient can't get a zero timeout: AS-2 exists only with a broker client, which requires a gateway entry, and the timeout is set with the entry.
  • The AS-1 adapter now takes its bounds from the core, so there is one source of truth, and it refuses target lifetimes above 300s.

@ChrisJBurns
ChrisJBurns merged commit 190f732 into main Nov 24, 2026
79 of 81 checks passed
@ChrisJBurns
ChrisJBurns deleted the feat/identitybroker-settings branch November 24, 2026 16:04

This branch was successfully deployed

1 active deployment
Preview — d6e40ef3 Deployed Nov 24, 2026 by vercel[bot]
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.

Identity broker settings

2 participants