You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: store the raw access token in the session cookie so tokens can carry more claims #278
The access cookie (seamless-access, built by issueSessionCookies) is an HS256 JWT whose claims include the whole API access token as a string. Every claim in the access token is therefore base64url encoded twice, about 1.78 bytes of cookie per byte of claims. RFC 6265 section 6.1 only requires browsers to support 4096 bytes per cookie, and a larger cookie is dropped, which signs the user out.
That caps how much authorization data a token can carry. With separate 1 KiB budgets for permissions and custom claims, the worst-case cookie measured 5670 bytes. For v0.23 the API shares one 1 KiB budget across permissions, organization roles and custom claims (ADR 0005 E6, fells-code/seamless-auth-api#584), which keeps the worst case at 3868 bytes. A larger budget needs the cookie to change.
What
Keep the API's access token as its own cookie, unwrapped. It is already signed by the API and verified against JWKS, so the adapter's HS256 wrapper adds no integrity.
Move the user details now in the wrapper (email, phone, roles, organization) into a second small cookie, or read them from the token.
Migrate existing cookies once: accept the old wrapped form until it expires, and issue only the new form.
Do the same in every adapter that issues or reads the session cookie: Express, Fastify and Next.js here, and seamless-auth-go, seamless-auth-python and seamless-auth-rust.
Add a conformance scenario in seamless-cli verify/harness for the new cookie format and the migration.
Then raise the shared budget in the API. Raising it only adds room, so tokens minted earlier stay valid.
Estimate, not measured: a raw-token cookie at both full 1 KiB budgets would be about 3730 bytes.
Done when
Every adapter stores the raw access token in its own cookie and migrates old cookies, conformance holds them to it, and the API's authorization claims budget is raised with a cookie test proving the worst case still fits in 4096 bytes.
Activity