Repository navigation
feat: recovery sessions and account notices for the v0.20 auth server - #233
Merged
Merged
Conversation
Guards refuse an access token carrying recovery: true with 403 enrollment_required unless allowRecoverySession is set (Express and Fastify requireAuth, Next.js session helpers). On manifest routes marked notices: true, an adapter with messaging names the notice kinds it can send in x-seamless-auth-delivery-kinds and delivers the returned account_notice_email / account_notice_sms items. If none goes out it cancels the recovery request with the token in the cancel link and answers 503 recovery_notice_failed. A recovery OTP is worded as one. Updates @seamless-auth/types to 0.31.0 and the bundled manifest. Refs #232
4 tasks
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.
Part of #232: the v0.20 contract pieces. The hardening issues #225 to #231 are in a separate PR. Updates
@seamless-auth/typesto 0.31.0 (core, nextjs) and syncs the bundled manifest from the API'sadapter-manifest.json.Recovery sessions
authenticateCookie/authenticateBearer/authenticateRequesttakeallowRecoverySession. Without it, an access token carryingrecovery: trueis refused with403 { error: "enrollment_required" }. For cookies the claim is read from the API token inside the cookie; for bearer, from the verified claims.requireAuth({ allowRecoverySession }). Next.jsgetSeamlessSession/getSeamlessClaimstreat a recovery session as signed out unless the option is set.hasSeamlessSessionstill reports it, since the session can use the auth routes to enroll.POST /auth/refreshreturns a token without it once the API has lifted the restriction. The React SDK will refresh after enrollment (react#185).ensureCookies, which the hardening PR touches.Account notices (fells-code/seamless-auth-api#500)
deliverAuthMessagehandlesaccount_notice_email/account_notice_sms.sendAccountNoticeEmail/sendAccountNoticeSmsand overridesaccountNoticeEmail/accountNoticeSms.deliverableNoticeKinds(messaging)lists only the kinds the configuration can really send (email transport or notice handler; same for SMS).handleManifestRouteon anotices: trueroute, when at least one kind is deliverable:x-seamless-auth-delivery-kindsdeliveries, then strips the field/recovery/cancelwith the token from thecancelUrlfragment and answers503 recovery_notice_failed. Failures log the error name only, never the link.purpose: "account_recovery"is worded as a recovery code, andpurposeis passed to custom OTP handlers and overrides.parseAdapterManifestaccept the optionalnotices: true.Routes
The new API routes (
/recovery/*,/recovery-codes*,/recovery/requests*,/system-config/policy*) are served by the existing manifest catch-all, as AGENTS.md describes. They now appear in the bundled fallback manifest too.403 step_up_required,409 secret_requiredand409 policy_version_conflictpass through as before viareadPassthroughFailure.Checks
pnpm build: clean.pnpm test: core 442, express 218, fastify 182, nextjs 180, all passing.deliverableNoticeKinds, and the notice-route proxy (headers, delivery, one of two sent keeps the request, none sent cancels and answers 503).pnpm check:types-current: current.Changeset: minor for core, express, fastify and nextjs, because refusing recovery sessions by default is a behaviour change. Under 0.x a minor marks it.