Repository navigation
2FA: draw the authenticator QR code in the browser - #258
Merged
Merged
Conversation
Both setup dialogs (profile and the enforced setup at sign-in) loaded the QR code as an image from api.qrserver.com. The CSP only allows `img-src 'self' data:`, so a production image showed a broken picture and the authenticator app could only be set up by typing the key. Without the CSP the request would have carried the TOTP secret to that service. The code is now an inline SVG built from the otpauth URI with `uqr` (no dependencies of its own): nothing leaves the page. It stays dark on white in dark mode and has the four-module quiet zone scanners expect. The 2FA e2e spec only spoke to the API, which is why this went unnoticed. It now opens the dialog against the production image and asserts that the code is drawn, that no request leaves the origin and that the CSP is not violated. The spec also signs in with the e-mail address: a created user's user name is the address, no longer the acronym, so the spec was red on develop before this. 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.
The QR code in the authenticator setup was a broken image on every production image, so an authenticator app could only be set up by typing the key.
Both setup dialogs (profile → security, and the enforced setup at sign-in) loaded the code as an image from
api.qrserver.com. The CSP only allowsimg-src 'self' data:, which refuses that image. Without the CSP the request would have carried the TOTP secret to that service.What changes
QrCode.vue: builds an inline SVG from theotpauth://URI in the page — nothing leaves the origin. Dark on white in dark mode too, with the four-module quiet zone scanners expect.uqr0.1.3 (MIT, no dependencies of its own) for the QR encoding.MfaSetupModal.vueandSecureSetupModal.vueuse the component.50-2fa.spec.tsopens the profile dialog against the production image and asserts that the code is drawn, that no request leaves the origin and that the CSP is not violated. The spec only spoke to the API before, which is why this went unnoticed. It also signs in with the e-mail address now: a created user's user name is the address, no longer the acronym, so the spec was already red ondevelop.Tests
pnpm type-checkandpnpm buildpass.50-2fa.spec.tsagainst a production image built from this branch: 3 of 3 green.api.qrserver.comin both dialogs.The rest of the Playwright suite is red on
developfor unrelated reasons and no workflow runs it; that is not part of this change.🤖 Generated with Claude Code