Repository navigation
refactor: serve passthrough routes from the manifest and align guard and 404 responses - #268
Merged
Merged
Conversation
…and 404 responses Delete the static passthrough tables in the three bindings so those routes come from the adapter manifest, which strips tokens from cookie-transport bodies. Express and Fastify apply the recovery enrollment refresh to manifest routes, as Next.js already did. POST /users/update is dropped: the auth API has no such route. requireAuth answers 401 unauthenticated and requireRole answers 403 insufficient_role without echoing roles. Express answers unmatched auth paths with a JSON 404. OTP verify, magic link verify and poll, and organization switch strip tokens from incomplete cookie-transport bodies. setSeamlessLogger is re-exported from each binding, and the bindings log through it. A manifest workflow checks the bundled manifest against the auth API's. Closes #263
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.
Closes #263.
The JS adapters now route, refuse and log the way the Go, Python and Rust adapters do.
Passthrough routes come from the manifest
The static passthrough tables are deleted:
proxyWithIdentityin Express, andPROXY_ROUTESin Fastify and Next.js (40 routes). Before deleting them, I compared every entry against the bundled manifest and against seamless-auth-api main. Method, path and credential match for each one exceptPOST /users/update. The auth API has no such route, so the adapter was forwarding to a 404, and no client in the ecosystem calls it. That route is dropped.What changes for those routes, now that
handleManifestRouteserves them:tokenandrefreshToken./webAuthn/...becomes/webauthn/.... The API routes these case-insensitively, and/webauthnis its own spelling.rawflag. The CSV and NDJSON exports still stream.404 not_foundinstead of400 bad_request, which is what the Go adapter answers. No upstream call is made either way.POST /totp/enroll/verifyis still rotated at once, and the existing recovery parity test covers it through the manifest path.The dedicated handlers for admin users, sessions, system config and internal metrics stay. They turn failures into
{ error, details }(readUpstreamFailure), where the manifest proxy forwards the API's body verbatim. Moving them would change error bodies that callers read today.The four handlers that pass an incomplete session body through now strip tokens in cookie transport: OTP verify, magic link poll, magic link verify (which gains a
transportoption) and organization switch.Guard and 404 responses
requireAuth, missing credential401 "Failed to find authentication token required"401 unauthenticatedrequireAuth, invalid or ephemeral token401 "Invalid or expired session"401 unauthenticatedrequireRole, role not granted403 "Insufficient role"plusrequiredandactual403 insufficient_rolerequireRole, user with no roles403 "User has no roles assigned"403 insufficient_rolerequireRole, nothing authenticated401 "Authentication required"401 unauthenticated/auth/*pathnext()(app's own 404, HTML by default)404 not_found(JSON)The codes are now set in core (
UNAUTHENTICATED,INSUFFICIENT_ROLE), so the Next.js guard no longer remaps them.Logger
setSeamlessLoggerandSeamlessLoggerare exported from express, fastify and nextjs, and documented in each README. Everyconsole.warnandconsole.errorin the three bindings goes throughgetSeamlessLogger(). Fastify's ownrequest.logcalls stay as they are. The unhandled-route-error line is now a single string, with the redacted detail appended.Manifest drift check
scripts/check-adapter-manifest.mjscompares the bundled manifest's routes with the ones seamless-auth-api main publishes, ignoringapiVersion. The newmanifestworkflow runs it on PRs, on pushes to main and daily, matching the Go, Python and Rust repos. Today the bundled copy (API 0.21.0) lists the same 130 routes as main (0.21.1).Release
Changeset:
minorfor core, express, fastify and nextjs. The changeset body describes the response changes.Tests
GET /organizations) strips tokens from its cookie-transport body. The Next.js guard parity now compares error bodies as well as statuses, across every refusal scenario.requireRolebodies are asserted exactly, with no roles echoed./users/updateis no longer served.setSeamlessLogger, and notconsole.The conformance workflow runs on this PR.
Downstream
seamless-auth-docs
build/express-without-jwt.mdxquotes the oldrequireAuthbodies. It needs a follow-up edit once this releases. No other sibling repo matches the old strings.