Repository navigation
Releases
Releases · sajanv88/next-identity-server
nextidp 0.1.5
Fastify
nextidp/fastify, for Fastify 5 (an optional peer dependency).auth.fastify()is a
plugin that answers nextidp's routes and reads the session for every request, refreshed
before it expires, in every plugin and prefix of the app;auth.sessionOf(request)gives
it.auth.requireSession()andauth.requireToken({ scopes })are hooks for a route's
onRequest(orpreHandler), andauth.tokenOf(request)gives the checked token. As with
Hono, a token that can't be checked now gets 503. The sign-out form needs no form parser,
and a refreshed session's cookie goes out beside the route's own.
nextidp 0.1.4
Sign-in
GET <basePath>/login?prompt=…passesprompton to the auth server:login,consent
orselect_account, or several separated by spaces. Any other value,noneincluded, is
left out, and nothing else in the query is passed on.signInPath(returnTo, { prompt })
builds the link.reauthenticateAfterSignOut(defaultfalse): a sign-out leaves a small marker cookie
(<prefix>.signed-out,__Secure-on https, onbasePathonly, 30 days), and the next
sign-in sendsprompt=loginand clears it, so a shared computer doesn't sign the next person
in as the last. A link withreauthenticate=false(a "Create account" link) opts out and
leaves the marker; apromptin the link wins over it.userinfo(defaultfalse): the email,email_verified, name and picture from the
userinfo endpoint, merged intosession.userafter sign-in and after a refresh that brings
a new ID token (kept otherwise), for auth servers that leave them out of the ID token.
Best effort: a failure, or an answer about anothersub, goes toonErrorand the
sign-in goes ahead.session.claimsstays the ID token's.
Next.js
routes()answers a fetch of the login route by Next's client router (a<Link>,
router.pushor a prefetch: therscheader) with a 200 "Sign-in needs a full page load."
and no cookie, instead of a redirect it can't follow. The router then loads it as a whole
page, and a sign-in under way keeps its flow cookie.
nextidp 0.1.3
Hono, and edge runtimes
nextidp/hono:routes(),middleware()(the session asc.get("session"), refreshed
before it expires),requireSession()andrequireToken()(the token as
c.get("token")), with theIdpEnvtype fornew Hono<IdpEnv>(). A refreshed cookie
reaches any response the handler makes, its ownResponseincluded.- Runs on edge runtimes (Cloudflare Workers, Vercel Edge, Deno, Bun): the tests bundle the
core and the Hono adapter for a platform without Node built-ins and run them in Cloudflare's
workerd, with no Node compatibility: sign-in, refresh, sign-out, back-channel logout,
API tokens and service tokens.
v1.2.1
What's Changed
Full Changelog: v1.2.0...v1.2.1
nextidp 0.1.2
The first release with code in it: sign-in for Next.js, Express and Node, API protection
for NestJS, Express and Next.js, service tokens, and sessions in a store with back-channel
logout.
Sign-in for Next.js (App Router)
idp()fromnextidp/next:routes(),proxy(),session(),requireSession().- The core from
nextidp, without a framework:handler(),getSession(),
refreshIfNeeded(),userInfo(),signInPath(). - The authorization code flow with PKCE (S256), the state and nonce checked, and the ID token
verified (signature,iss,aud,azp,exp,iat, nonce). - The session in an encrypted cookie (A256GCM, a key per purpose from HKDF), split when it's
over 4 KB, with secret rotation. - Refresh before expiry in the proxy, shared between concurrent requests. Sign-out revokes
the refresh token, and can end the auth server's session too (RP-initiated logout). - ES module and CommonJS builds, with types for each.
Sign-in for Express and Node
nextidp/express:express()middleware (nextidp's routes, and the session read and
refreshed on every other request),requireSession()andsessionOf(req).nextidp/nodefor Node's own HTTP server:handle(req, res),session(req, res)and
requireSession(req, res).- A signed-out GET goes to sign in and comes back after; anything else gets 401.
- The URL is always on
appUrl's origin, never from the Host header. Forms a body parser
already read are taken from it; others are read up to 64 KB (413 past that). - A refresh happens only while the response's headers can still be set, so a rotated refresh
token is never lost.
Sessions in a store, and back-channel logout
- The
storeoption (SessionStore:get,set,deleteover strings), and
memoryStore()for one process. The cookie then holds only a sealed reference, and the
stored session is sealed too. - Signing out deletes the stored session, so a copy of the old cookie is signed out as well.
A new sign-in replaces the browser's previous session. POST <basePath>/backchannel-logout(OIDC Back-Channel Logout 1.0), with a store only:
the logout token is checked (signature,iss,aud,iat,exp, the logout event, a
sidorsub, nononce,typlogout+jwt when there is one), then the app's sessions
from that auth-server session end; a token with onlysubends all of the person's
sessions begun before it. 400 for a token that doesn't verify (invalid_logout_token).- A refresh refused because another instance sharing the store refreshed first keeps the
session that instance stored. - Apps sharing a store are kept apart by their client ID.
Service tokens
serviceToken({ scopes, resource })in the core: a service's own access token (client
credentials, a confidential client), kept until a minute before it expires (half its life
if that's shorter), per scopes and API, with one request at a time.dropServiceToken(token)forgets one an API refused.useServiceToken(client, options)
puts tokens on the requests of a fast-http-client client to the API's origin (that of
resource, ororigins) and nowhere else, and on a 401 gets a new one and sends the
request once more.- A refusal is
IdpErrorwith the codeservice_token_failed, and isn't kept. - NestJS: inject
IDPand callserviceToken().
Protecting an API
verifyAccessToken()andverifyBearer()in the core: a JWT access token checked against
the issuer's keys (signature,typat+jwt,iss,aud, expiry), an opaque one by
introspection (kept a minute at most), then the scopes a route needs.- 401 and 403 with RFC 6750's
WWW-Authenticatechallenge (tokenErrorResponse()), 503
when a token can't be checked at all. nextidp/nestjs:IdpModule.forRoot()andforRootAsync(), a guard on every route by
default,@Scopes(),@Public(),@CurrentToken(). NestJS 11 (CommonJS) and 12 (ES
modules).nextidp/express:requireToken()middleware andtokenOf(req).nextidp/next:withToken()for route handlers.- An API needs only
issuerandaudience(IDP_AUDIENCE), required and never taken from
resource. A JWT access token must havetypat+jwt. An introspected token must name the
audience too, unlessacceptOwnTokenslets this client's own tokens through. - Nothing from the HTTP client reaches an error or a log: a failed request keeps only its
message, and the adapters log error codes. resourceandaudienceare kept exactly as written: the auth server compares them as
strings.- Node 24 or later.
v1.2.0
What's Changed
- feat(post-logout-redirect): sign out of the auth server from an app (RP-initiated logout) by @sajanv88 in #42
Full Changelog: v1.1.6...v1.2.0
v1.1.6
What's Changed
- docs: step-by-step guide at /docs, and a new README by @sajanv88 in #37
- fix(landing): open a page at its top after a navigation by @sajanv88 in #38
- fix(admin): accept localhost redirect URIs in development and explain client refusals by @sajanv88 in #39
- feat(admin-users): user management for admins by @sajanv88 in #40
- feat(admin): user page with sessions, loading screens and error states by @sajanv88 in #41
Full Changelog: v1.1.5...v1.1.6
v1.1.5
v1.1.4
What's Changed
- feat(telemetry): tracing per auth step and web vitals (LCP, INP, CLS) over OpenTelemetry by @sajanv88 in #29
- feat(oidc): edit, copy ID, actions menu, pagination, and a tab icon by @sajanv88 in #31
- feat(email): emails built with React Email by @sajanv88 in #30
- ci(main): a failed cache export no longer fails a published build by @sajanv88 in #32
- feat(my-profile): my profile account settings in vertical tabs, sessions paged by @sajanv88 in #33
Full Changelog: v1.1.3...v1.1.4
v1.1.3
What's Changed
- feat(landing): tokens for your own APIs, client credentials and back-channel logout by @sajanv88 in #27
- feat(branding): configurable product name (APP_NAME) and logo (LOGO_URL) by @sajanv88 in #28
Full Changelog: v1.1.2...v1.1.3