Repository navigation
fix(vue,svelte,angular): route recovery sessions to factor enrolment - #252
Merged
Merged
Conversation
A recovery session can do nothing but enroll a new factor, but only the React login screen sent it there. The Vue, Svelte and Angular login screens now go straight to register-passkey for a recovery session, and their requireAuth guards redirect it to the new enrollmentPath config option (default /register-passkey) before any role check. The enrollmentRedirectTo guard option overrides it per route, and a guard on the enrolment route itself admits the session instead of looping. Angular's SeamlessAuth service gains redeemRecoveryCode and completeAccountRecovery, which refresh the session afterwards as the other frameworks do. Closes #242
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 #242 (M18, part of fells-code/seamless-auth-api#603).
Problem
Only the React login screen sent a recovery session to passkey enrolment. The Vue, Svelte and Angular login screens let it sit on the sign-in form, and their
requireAuthguards tested onlyisAuthenticated, so a recovered account reached protected routes with a restricted session that only the server'senrollment_requiredstopped. Angular also had noredeemRecoveryCodeorcompleteAccountRecoveryon its service, so calling the client directly skipped the session refresh andrecoverySessionnever turned true.Changes
SaLogin, SvelteLogin.svelte, AngularSaLogin): whenrecoverySessionis true, on mount or once a refresh turns the session into one, they navigate to the bundledregister-passkeyscreen through the package's own screen navigation, matchingpackages/react/src/views/Login.tsx.requireAuthguards: a recovery session is redirected to factor enrolment before any role check. The target is the newenrollmentPathconfig option (default/register-passkey, alongsideloginPath), overridable per guard withenrollmentRedirectTo. When the route being guarded is already the enrolment target the guard admits the session, so guarding the enrolment route itself does not loop. Angular reads the target from the router state forcanActivateand from the URL segments forcanMatch.redeemRecoveryCodeandcompleteAccountRecoverywrap the session actions, which refresh the session afterwards like Vue and Svelte.enrollmentPath,enrollmentRedirectToand the new Angular actions.Decisions
requireAuth, so the changeset isminorfor@seamless-auth/vue,@seamless-auth/svelteand@seamless-auth/angular.requireAuth, so a recovery session can still reachregister-authenticatorfrom the passkey screen. An app that guards both enrolment screens can pointenrollmentRedirectToat whichever it wants.toScreenhelpers rather than a history replace, so no navigator interface changes (Svelte'sAuthNavigatoris implementable by applications).Tests
enrollmentRedirectTo/enrollmentPathare honoured (Angular coverscanMatchtoo).register-passkey, and so does a session that becomes one afterrefreshSession.recoverySession.npm run typecheck,npm run lint,npm run format:checkandnpm test(Jest and the Svelte Vitest suite) pass.