Repository navigation
Two-factor sign-in with an authenticator app - #24
Merged
Merged
Conversation
Users can turn on two-factor sign-in under Two-factor sign-in in their account menu: they add a secret to an authenticator app by QR code or by hand, and confirm it with a code (TOTP, RFC 6238, implemented here). That signs them out everywhere else and shows ten recovery codes once, each good for one sign-in. Signing in then asks for a code after the password; a sign-in waits for it five minutes, five tries at most, and wrong codes count against the client's budget. No code works twice. Scripts send the code with the password, or answer the challenge the login returns. Turning it off and making new recovery codes take the password. Superadmins, or goftp user two-factor-off, turn it off for someone who lost their app. App passwords are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Stacked on #23 (folder sharing), which is stacked on #22 (chunked WebDAV uploads). Merge #22, then #23, then this one.
What it does
/.auth/two-factor). Setup:goftp user two-factor-off NAME.POST /.auth/loginwith"code";401 {"two_factor":true,"challenge":"…"}with{"challenge","code"};POST /.auth/two-factorwithaction=start|confirm|codes|off, answered in JSON.How it works
totp_step < $2), so no code works twice, even in two parallel sign-ins.rsc.io/qr(BSD, pure Go), only to encode the QR code, which is drawn as inline SVG.users.totp_secret,totp_pending,totp_stepand therecovery_codestable.Tests
internal/auth/twofactor_test.go, on both the memory and Postgres stores:internal/server/twofactor_test.go:two-factor-off.-race+ Postgres on macOS (except the known macOS-onlyTestLongNonASCIIPath).otpauth://URI;🤖 Generated with Claude Code