mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-01 16:36:06 +00:00
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. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
9323d61743
commit
d34b1eb2bf
10 changed files with 50 additions and 15 deletions
|
|
@ -68,8 +68,9 @@ OTP_LINK_MAX_AGE = 3600
|
|||
|
||||
def send_email_with_otp(request, user):
|
||||
"""Mail the user a link to the page of their OTP QR code, good for
|
||||
OTP_LINK_MAX_AGE: the QR code's secret is never in a mailbox."""
|
||||
url = request.build_absolute_uri(reverse("accounts:otp_qr", args=[OTP_LINK.sign(str(user.pk))]))
|
||||
OTP_LINK_MAX_AGE: the QR code's secret is never in a mailbox. The token
|
||||
is the URL's fragment, which no request carries: it is in no access log."""
|
||||
url = request.build_absolute_uri(reverse("accounts:otp_qr")) + "#" + OTP_LINK.sign(str(user.pk))
|
||||
send_mail(
|
||||
_("OTP QR Code"),
|
||||
_("Open this link within an hour to see the OTP QR code of account '%(user)s':\n\n%(url)s")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue