Initial mfa support (for internal users) #93591

Merged
Oleg-Komarov merged 46 commits from mfa into main 2024-08-29 11:44:06 +02:00
Owner

added support for totp, u2f (yubikey) and recovery codes

TODO out of scope for this PR

  • replace admin login with LoginView
  • remove SwitchUserView
added support for totp, u2f (yubikey) and recovery codes TODO out of scope for this PR - replace admin login with LoginView - remove SwitchUserView
Oleg-Komarov added 43 commits 2024-08-27 13:10:40 +02:00
without key encryption at rest, reimplement with a custom Device class
Anna Sirota reviewed 2024-08-27 14:36:52 +02:00
@ -0,0 +3,4 @@
A new {{ device_type }} multi-factor authenticator has been added to your Blender ID account {{ user.email }}
If this wasn't done by you, please reset your password immediately and contact blenderid@blender.org for support.
Owner

might be out of scope, but setting an ADMIN_EMAIL (like in DevFund) or SUPPORT_EMAIL (not to be confused with builtin settings.ADMINS) configuration variable and passing it to the templates that need it is more maintainable than hard-coding it in multiple files.

might be out of scope, but setting an `ADMIN_EMAIL` (like in DevFund) or `SUPPORT_EMAIL` (not to be confused with builtin `settings.ADMINS`) configuration variable and passing it to the templates that need it is more maintainable than hard-coding it in multiple files.
Oleg-Komarov marked this conversation as resolved
@ -0,0 +79,4 @@
<p>
Store your recovery codes safely (e.g. in a password manager or use a printed copy) and don't share them.
Each code can be used only once.
You can generate a new set of recovery codes at any time, any remaining old codes will become invalidated.
Owner

will become invalidated.

"will be invalided" or "will become invalid"

> will become invalidated. "will be invalided" or "will become invalid"
Oleg-Komarov marked this conversation as resolved
@ -0,0 +69,4 @@
for device in devices_for_user(self.request.user):
device.delete()
if self.request.user.confirmed_email_at:
bid_main.tasks.send_mfa_disabled_email(self.request.user.pk)
Owner

DevFund and other services use send_mail_* for the most part: it's easier to parse visually

DevFund and other services use `send_mail_*` for the most part: it's easier to parse visually
Oleg-Komarov marked this conversation as resolved
@ -0,0 +82,4 @@
):
# Forbid setting up recovery codes unless the user already has some other method
return HttpResponseBadRequest("can't setup recovery codes before other methods")
user.staticdevice_set.all().delete()
Owner

From this line it's not clear that this is recovery codes that are being deleted

From this line it's not clear that this is recovery codes that are being deleted
Oleg-Komarov marked this conversation as resolved
@ -0,0 +94,4 @@
class InvalidateRecoveryView(mixins.MfaRequiredIfConfiguredMixin, View):
def post(self, request, *args, **kwargs):
user = self.request.user
user.staticdevice_set.all().delete()
Owner

same as above

same as above
Oleg-Komarov marked this conversation as resolved
@ -0,0 +139,4 @@
class U2fRegisterView(mixins.MfaRequiredIfConfiguredMixin, FormView):
form_class = U2fRegisterForm
success_url = reverse_lazy('bid_main:mfa')
template_name = "bid_main/mfa/u2f_register.html"
Owner

is context['first_device'] = not devices_for_user(self.request.user) necessary here as well?

is `context['first_device'] = not devices_for_user(self.request.user)` necessary here as well?
Oleg-Komarov marked this conversation as resolved
@ -0,0 +132,4 @@
self.clean_agent()
return self.cleaned_data
def save(self):
Owner

might not be necessary at all, since this isn't a ModelForm?

might not be necessary at all, since this isn't a `ModelForm`?
Oleg-Komarov marked this conversation as resolved
Márton Lente added 1 commit 2024-08-27 16:04:36 +02:00
Oleg-Komarov added 1 commit 2024-08-29 11:29:06 +02:00
Oleg-Komarov added 1 commit 2024-08-29 11:34:17 +02:00
Anna Sirota approved these changes 2024-08-29 11:42:01 +02:00
Anna Sirota left a comment
Owner

Awesome sauce 🎉
Great to see long awaited MFA finally happening!

Awesome sauce :tada: Great to see long awaited MFA finally happening!
Oleg-Komarov changed title from WIP: mfa to mfa 2024-08-29 11:42:27 +02:00
Oleg-Komarov changed title from mfa to Initial mfa support (for internal users) 2024-08-29 11:42:48 +02:00
Oleg-Komarov merged commit f37212966f into main 2024-08-29 11:44:06 +02:00
Oleg-Komarov deleted branch mfa 2024-08-29 11:44:06 +02:00
Sign in to join this conversation.
No description provided.