Repository navigation
feat(auth): draw the two-factor QR code on the server - #183
Merged
Merged
Conversation
… and leave the setup address out of the page
Owner
|
Thank you, @ertugrulkeyvan, merged. Sending the otpauth address, and the shared secret in it, to a public QR service was a real leak, and drawing the code on the server closes it. We read the generated code back with a QR reader and it decodes to exactly the otpauth address, and nothing in PNLCS or its Docker image blocks a Full suite green. |
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.
What
The two-factor setup screens draw their QR code on the server instead of loading it from a public QR service.
Both setup screens, the staff one (
admin/auth/enable-two-factor) and the customer one (client/auth/enable-two-factor), loaded the code from api.qrserver.com, with theotpauth://setup address in the request:After this:
bacon/bacon-qr-codeis already required, and the invoice PDF already uses it for its payment QR. The SVG back end needs no PHP extension.A note for the release notes, if you think it fits: accounts that set up two-factor sign-in through the old screens sent their setup address to that service. Turning two-factor off and on again gives them a new secret.
How
App\Support\QrCode::dataUri(): draws the code with bacon-qr-code'sImageRendererandSvgImageBackEndand returns adata:image/svg+xml;base64,URI.Admin\AuthController::enable2fa()andClient\AuthController::enable2fa()pass it to the view as$qrImage.$qrUrlis still passed, so a theme that overrides the view keeps working until it switches over.$qrImage.The work is split into four commits: the helper, the staff screen, the customer screen and the tests.
Tests
tests/Feature/TwoFactorQrLocalTest.php, 3 tests:qrserver.com, an inline SVG image, and nootpauthaddress anywhere in the page.They fail on
main.AdminTwoFactorReachableTestandTwoFactorBackupCodesShownTestpass unchanged.Full suite: 4089 passed. The one failure is the
CurrencyAndBackupTestdb backup test, which fails onmaintoo in my local setup.