Repository navigation
fix(core): check a silently refreshed token against authServerIssuer - #198
Merged
Merged
Conversation
The Release workflow on main failed in packages/core: two tests in ensureCookies.test.js expected verifySignedAuthResponse to be called with three arguments and received a fourth, undefined. #193 (silent refresh verification) and #192 (authServerIssuer) were written in parallel and merged minutes apart. #192 gave verifySignedAuthResponse and issueSessionCookies an issuer argument and threaded it through every flow that issues a session; #193 routed the silent refresh through issueSessionCookies without it. So the tests were stale, and the silent refresh also ignored a configured authServerIssuer: an app reaching the auth server at another URL (the local Docker stack from the host) got a 401 on every silent refresh and was signed out. Add authServerIssuer to EnsureCookiesOptions and the Express createEnsureCookiesMiddleware options, pass it to issueSessionCookies, and have the Express, Fastify and Next.js adapters pass their configured value. The JWKS verification of the refreshed token is unchanged and still fails closed. Update the core assertions for the issuer argument, and cover the silent refresh with a configured issuer, and from an unexpected one, in the Express middleware tests and the Fastify and Next.js issuer parity suites.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mainhas failed the Release workflow since ca8fa4a: 2 tests inpackages/core/tests/ensureCookies.test.js(run 37564480523). Two PRs merged minutes apart:authServerIssuerargument toverifySignedAuthResponse,verifyUpstreamSession, andissueSessionCookies, and threaded it through every flow that issues a session.ensureCookiesthroughissueSessionCookieswithout passingauthServerIssuer.So, besides the stale test assertions, there was a real bug: the silent refresh checked
issagainstauthServerUrleven whenauthServerIssuerwas configured. An app that reaches the auth server at a different URL from its issuer (for example, the local Docker stack run from the host, seamless-cli#224) got a 401 on every silent refresh and was signed out. It failed closed, so it was not a security hole.Fix
core:EnsureCookiesOptionsextendsAuthServerIssuerOptionand passesauthServerIssuertoissueSessionCookies.express(createEnsureCookiesMiddleware,createServer),fastify(ensureCookies hook), andnextjs(handler) pass their configuredauthServerIssuer. The new option is optional, so no existing caller breaks.ERR_JWS_SIGNATURE_VERIFICATION_FAILEDline in the failing log comes from a passing negative test inverifySignedAuthResponse.test.jsand also appears on green runs.Tests
authServerIssueris accepted, and one with an unexpected issuer gets 401.issuer.parity.test.js, kept as mirrors): the same two scenarios against each adapter and Express.Patch changeset for core, express, fastify, and nextjs. It ships with the unreleased #192 and #193 changesets.
Testing
On Node 24:
pnpm install --frozen-lockfile,pnpm check:types-current,pnpm build, andpnpm testpass (core 342, express 203, nextjs 155, fastify 146). CI covers Node 22 and latest.