Skip to content

fix: bind provider lookups to the asking client's grant when a session has several - #524

Merged
Bccorb merged 1 commit into
mainfrom
fix/oidc-grant-binding-per-client
Oct 31, 2026
Merged

Bccorb merged 1 commit into
mainfrom
fix/oidc-grant-binding-per-client

Conversation

@Bccorb

@Bccorb Bccorb commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

What

hasOidcGrantForSession read one Grant row for the session and then compared its clientId. A first-party session signed in to more than one client holds one grant per client, so the row that came back could belong to another client and the check failed. /oidc/sign, GET /oidc/accounts/:id and GET /oidc/sessions/:id/auth-context all go through it, so the second app a user signs in to from the hosted pages would be refused.

The client is now part of the query (payload.clientId, a JSONB match). The equality check after it stays as a second guard.

Why now

The login edge (seamless-auth-oidc-provider#2) keeps one first-party session across apps, which is exactly the case this broke. Found while wiring interactions there.

Part of #387. Small and on its own, so it can merge independently of the other v0.21 API work.

Checks

  • New Postgres test: one session with grants for three clients finds each. It fails on main and passes here.
  • TEST_DB=postgres npx vitest run --project postgres: 48 passed
  • npm run typecheck, npm run lint, prettier --check src tests: clean
  • npm run coverage: 2536 passed, 98.99% lines, 95.69% branches

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