Repository navigation
feat: persistent sessions with rotating remember tokens - #328
Merged
Merged
Conversation
…r in the changeset
…rade notes and threat model
|
| const auth = await persistentAuth(); | ||
| const app = express(); | ||
| app.use(express.json()); | ||
| app.use(BASE_PATH, theAuthMiddleware({ theauth: auth })); |
| options: SessionRefresherOptions = {}, | ||
| hooks: RefresherHooks = {}, | ||
| ): SessionRefresher { | ||
| const base = (options.basePath ?? "/api/theauth").replace(/\/+$/, ""); |
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.




What ships
Persistent sessions ("keep me signed in"), off until you set
auth.session.persistent.POST /auth/session/refresh, reuse detection, a grace window for parallel tabs and instances, device list, rename, forget and revoke, andrefreshFromRequestfor server rendered pages. Migration0016adds two tables.rememberworks across password, second factor, passkey, OAuth, magic link, email code, phone, One Tap and native app exchange, including routes that answer with the token in JSON.refreshPageSessionfor Next.js, Hono, Express, Fastify, NestJS, Nuxt, Astro, SvelteKit, SolidStart and TanStack Start.@glinr/theauth-nextjs-authtakes apersistentoption for a theAuth backend.session_expired, tab sync,usePersistentSession(), external auth support, andrememberon the theauth-go client and its query hooks.sso.authorizeConnectionRoutesgates connection create, list and delete, andsso.handleLoginRequestserves only the sign-in and callback routes. The doctor reportssso.connection_routes_openwhen neither is in use.examples/persistent-sessions.cross-spawnto 7.1.0 or later,ws7.x to 7.5.14 or later andtarto 8.0.5. Zod 4, which only development tooling andagent-frameworkstests install, moves to 4.6.7.Upgrade steps
persistent.idleTimeoutMs(30 days by default) is longer than the sessionmaxAge, or startup fails.0016. It runs at startup unless you useskipMigrationsor D1. Prisma users copy the two new models. SQL Server users runapplyMssqlSchema.auth.session.persistentwith a secret of at least 32 bytes, the same on every instance.rememberand to refresh once onsession_expired.sso.authorizeConnectionRoutesor mountsso.handleLoginRequest.Behaviour to check once it is on:
rememberMe: trueno longer lengthens the session itself, password changes and resets end remembered devices, and aPOSTsign-in on a JSON route sets no remember cookie when itsOriginis not your own or a trusted one. Full list indocs/persistent-sessions-upgrade.mdx.Limits
handleRequestroutes do not receivetrustedOrigins. A frontend on another origin should use the routes served bycreateTheAuthHandler.createTheAuth.createSessionRefreshercovers it), and it needs a theauth-go server that supports persistent sessions.tar8 requires Node 22, and itsextract()without a file now returns a promise, which the@mapbox/node-pre-gypinstall command does not expect. Here that package is only used by@vercel/nftfor path lookup, which does not call it.Checks
Build (34 of 34), lint and typecheck (53 of 53) pass. The test suite reports 16974 passed, 0 failed and 590 skipped; the skips include the Postgres and MySQL persistent session suites, which need a live database. The persistent sessions example runs to the end, the docs link check passes, the generated llms files are current and the production audit gate passes.
On a busy macOS machine the Express adapter tests can fail at random when the test client reaches another local server on the same port. One full run and one push hook run hit this, and the reruns passed.