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
|
|
@ -353,12 +353,15 @@ def email_otp(request):
|
|||
|
||||
|
||||
@login_not_required
|
||||
def otp_qr(request, token):
|
||||
"""The OTP QR code of the user a mailed link (send_email_with_otp) names."""
|
||||
def otp_qr(request):
|
||||
"""The OTP QR code of the user a mailed link (send_email_with_otp) names.
|
||||
The link's token is in its fragment: the page posts it (otp_qr.js)."""
|
||||
if not settings.OTP_ENABLED:
|
||||
raise Http404
|
||||
if request.method != "POST":
|
||||
return render(request, "accounts/otp_qr.html")
|
||||
try:
|
||||
user_id = OTP_LINK.unsign(token, max_age=OTP_LINK_MAX_AGE)
|
||||
user_id = OTP_LINK.unsign(request.POST.get("token", ""), max_age=OTP_LINK_MAX_AGE)
|
||||
except BadSignature:
|
||||
raise Http404
|
||||
user = get_object_or_404(get_user_model(), pk=user_id, is_active=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue