Skip to content

Re-check the user's upstream refresh token when issuing an ID-JAG #6978

Open

Description

@jhrozek

Part of #6886. Depends on #6898 (ID-JAG issuance) and the per-user rows of "User-keyed upstream storage behind the embedder option" (#7263) (and of "Re-authorization walks the full upstream chain instead of evaluating existing credentials" (#6831) for runner-built storage); uses the per-user revocation time (#6972). Related: #4122 (refresh-token rotation race across pods).

Problem: a grant lets a client get ID-JAGs for the user for days or weeks without the user present. If the company IdP disables the user in that time, nothing notices: the grant keeps working until it expires. A grant records the user, not an upstream session, and upstream tokens are stored per authorization session today, so the server cannot find the user's upstream refresh token from a grant.

Change:

  • One upstream refresh token per user (through the per-user rows of "User-keyed upstream storage behind the embedder option" (User-keyed upstream storage behind the embedder option #7263), and of "Re-authorization walks the full upstream chain instead of evaluating existing credentials" (Re-authorization walks the full upstream chain instead of evaluating existing credentials #6831) for runner-built storage), from the most recent sign-in, independent of any one client signing out. Record its expiry: the IdP's refresh_expires_in when it sends one, otherwise a configured maximum per IdP.
  • At ID-JAG issuance, and when deriving a child grant:
  • Refresh rules:
    • one refresh per user at a time across replicas, under a lease; the in-flight state is recorded before the IdP call;
    • a request waiting for the lease re-reads its grant afterwards, so it returns the revocation reason if the lease holder revoked it;
    • a lease timeout answers 503 with Retry-After and revokes nothing.
  • What the IdP answers:
    • success: store the new token, rotated or not, and the time;
    • invalid_grant before the recorded expiry and after a clean previous refresh: per-user revocation with upstream_revoked; discard the upstream token;
    • invalid_grant at or after the recorded expiry, or after an ambiguous previous refresh (this row wins when both apply): per-user revocation with owner_action_required; discard it. A refresh is ambiguous when one was in flight as the server crashed or lost the response, so it cannot know whether the IdP rotated the token;
    • network error or 5xx: 503 with Retry-After; nothing revoked.
  • The IdP must issue a refresh token at sign-in. Document and test, per supported IdP, what the sign-in must request (offline_access or its equivalent). With no refresh token, every issuance ends with owner_action_required, unless the operator has turned the re-check off for that IdP (off by default).
  • Configuration: the re-check interval; the maximum upstream refresh-token lifetime per IdP; the lease timeout; the per-IdP switch above.
  • Audit: upstream_recheck.refreshed, upstream_recheck.revoked, and upstream_recheck.refused log lines with the user, the IdP, and the outcome; never tokens.

Limits, documented: it catches an account disabled or grants revoked at the IdP within about one interval. It does not catch a plain sign-out at the IdP. ID-JAGs and access tokens already issued stay valid until they expire.

Acceptance:

  • a disabled upstream account ends the user's grants at the next issuance after the interval, with upstream_revoked;
  • a recorded expiry that has passed ends them with owner_action_required, with no call to the IdP;
  • an unreachable IdP gives 503 and revokes nothing;
  • concurrent issuances for one user across replicas make one IdP call;
  • a crash between the IdP call and storing the result does not turn the next invalid_grant into upstream_revoked;
  • a client signing out does not end grants while the upstream token is valid.

Activity

  1. added
    needs-triage
    on Oct 28, 2026
  2. removed
    needs-triage
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions