1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 17:06:09 +00:00
webvirtcloud/static/js/otp_qr.js
catborise 7edfdca2da fix(accounts): the mailed OTP link keeps its token out of the access logs
The link to the OTP QR code carried its signed token in the path, so
gunicorn's access log (docker logs, the journal) and nginx's held it:
anyone reading them within the hour could open the code and take the
TOTP secret. The token is now the URL's fragment, which no request
carries; the page posts it (otp_qr.js) and the answer shows the code.
2026-11-09 12:00:55 +03:00

8 lines
387 B
JavaScript

// The mailed OTP link carries its token after "#", which no request sends,
// so it is in no access log: the page posts it to get the QR code.
var otpQrForm = document.getElementById("otp-qr-form");
if (otpQrForm && location.hash.length > 1) {
otpQrForm.elements.token.value = location.hash.slice(1);
history.replaceState(null, "", location.pathname);
otpQrForm.submit();
}