The authenticator QR is black on nothing, which is nothing on a dark page #87
Labels
No labels
accessibility
authentication
breaking change
bug
documentation
enhancement
interface
internationalisation
observability
security
tier
1
tier
2
tier
3
tier/4
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Postulo/postulo#87
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Observation
What is wrong
allauth builds the QR with
qrcode'sSvgPathImagefactory. Generated and looked at ratherthan assumed, the whole image is:
One path, filled
#000000, and no background whatsoever — not even a white quiet zone.The only colour anywhere in the file is black.
On a light page that reads perfectly, which is why it shipped. On a dark page it is black on
near-black: not low contrast, invisible. No camera will find it, and nor will a person.
Setting up two-factor authentication is not a page anybody visits twice, so it is exactly
the kind of screen that goes years without being looked at in both themes.
The fix
Tag the image and invert it in the dark theme only:
A filter works on the colour channels and leaves alpha alone, so the modules flip to white
and the transparency stays transparent — the quiet zone becomes the page's own dark, which
is what a scanner wants: an unbroken margin of one colour that contrasts with the modules.
The class is attached through allauth's element system, which already tags this image
mfa,totp,qr, so no other image is affected — an avatar rendered through the same elementtemplate is untouched, and there is a test saying so.
Worth knowing: an inverted QR is not universally scannable
The symbology specification allows a reader to handle reflectance reversal, and modern phone
cameras generally do. Some older or simpler scanners do not, and expect dark modules on a
light field.
Left as asked, for two reasons. The alternative — a white plate behind the code in both
themes — is reliably scannable but puts a stark white card in the middle of a dark page,
which is the thing being complained about. And the failure is recoverable: the same page
shows the secret as text directly beneath the code, so anybody whose scanner refuses can
type it.
If a real scanner turns out to refuse it, the white plate is a one-line change.
Classification
Bug, accessibility. Present since the dark theme existed.