Skip to content

feat(identitybroker): authorize gateway calls with a per-call ID-JAG and gateway token - #2786

Merged
ChrisJBurns merged 1 commit into
mainfrom
split/2535-3-per-call-flow
Nov 16, 2026
Merged

ChrisJBurns merged 1 commit into
mainfrom
split/2535-3-per-call-flow

Conversation

@ChrisJBurns

@ChrisJBurns ChrisJBurns commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Part 3 of 4 for #2535. Stack: #2784 → #2785 → this PR → #2783.

Steps (7) and (8): each call gets an ID-JAG from AS-1 and redeems it at AS-2 for a one-call gateway token.

  • Ports IDJAGIssuer and GatewayAuthServer, implemented by authserverclient (IssueIDJAG, Redeem).
  • The flow: records each ID-JAG before redeeming it and the decision before returning the token; one retry allowance each for a lost response, a reasonless invalid_grant, and a revoked grant with a newer one; one rejected-token retry per issued attempt; revoked with nothing newer closes the session; a closed or expired session is re-checked before every try and before returning.
  • AS-2 is bound late (BindGatewayAS2), and unbinding waits for calls in flight.
  • Unit tests against fake ports for the paths real servers can't produce on demand.

Shortcuts (marked in code): AS-2 bound late in process (#2560); no authorization_details (#2727); gateway token unbound, lifetime from AS-2 (#2538, #2727); upstream_revoked/owner_action_required not recorded against the session (#2568); a non-JWT gateway token has no record reference (#2541).

API compatibility

No wire change: in-process until #2560.

@jhrozek jhrozek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed this PR's own commit (a9d9519178..be15152187).

The AS-1 exchange and the AS-2 redemption match steps (7) and (8), and the error mapping matches the error-reasons table. The session is checked again before every external step and before the token is returned. Retries are bounded at four tries, and an ID-JAG is never sent twice. The ID-JAG record and the success record are saved before redeeming and before returning. No secret reaches an error or a record.

One comment that can't go inline, because sessions.go isn't in this diff: the CloseSession comment at internal/identitybroker/sessions.go:208 says "Calls already in progress may finish." With this PR, a call in progress is refused with the closing reason at its next session check and gets no token, even after AS-2 has issued one. Could it say that instead?

Two small inline comments below.

Comment thread internal/identitybroker/authorize.go Resolved
Base automatically changed from split/2535-2-contract to main November 16, 2026 11:58
…and gateway token

A call that passes the checks exchanges the session's refresh token at AS-1
for an ID-JAG (IDJAGIssuer), records it, and redeems it at the gateway's
AS-2 (GatewayAuthServer) for a token used by that call alone, retrying once
per design rule. AS-2 is bound late with BindGatewayAS2; authserverclient
implements both ports.

Co-authored-by: Mecatl <noreply@mecatl.dev>
@ChrisJBurns
ChrisJBurns force-pushed the split/2535-3-per-call-flow branch from be15152 to 352a4d3 Compare November 16, 2026 12:00
ChrisJBurns added a commit that referenced this pull request Nov 16, 2026
…lowances

Address review comments on #2786:
- The retry-allowance table now checks one decision matching the returned
  error, one ID-JAG record per issued ID-JAG, no token on failure, and that
  the try after a revoked grant presents the session's new grant.
- Mark the dropped AS-2 error_uri as a shortcut removed by #2735.
- CloseSession's comment says a call in progress is refused at its next
  session check and gets no token.

Co-authored-by: Mecatl <noreply@mecatl.dev>
@ChrisJBurns
ChrisJBurns merged commit e54ef16 into main Nov 16, 2026
47 checks passed
@ChrisJBurns
ChrisJBurns deleted the split/2535-3-per-call-flow branch November 16, 2026 12:26
ChrisJBurns added a commit that referenced this pull request Nov 16, 2026
…lowances

Address review comments on #2786:
- The retry-allowance table now checks one decision matching the returned
  error, one ID-JAG record per issued ID-JAG, no token on failure, and that
  the try after a revoked grant presents the session's new grant.
- Mark the dropped AS-2 error_uri as a shortcut removed by #2735.
- CloseSession's comment says a call in progress is refused at its next
  session check and gets no token.

Co-authored-by: Mecatl <noreply@mecatl.dev>
ChrisJBurns added a commit that referenced this pull request Nov 16, 2026
…lowances

Address review comments on #2786:
- The retry-allowance table now checks one decision matching the returned
  error, one ID-JAG record per issued ID-JAG, no token on failure, and that
  the try after a revoked grant presents the session's new grant.
- Mark the dropped AS-2 error_uri as a shortcut removed by #2735.
- CloseSession's comment says a call in progress is refused at its next
  session check and gets no token.

Co-authored-by: Mecatl <noreply@mecatl.dev>
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Nov 18, 2026
2 tasks
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.

2 participants