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
2 changed files with 9 additions and 1 deletions
Showing only changes of commit 40f6f0555f - Show all commits

View File

@ -139,9 +139,11 @@ Profile
<a class="btn" href="{% url 'bid_main:active_sessions' %}"> <a class="btn" href="{% url 'bid_main:active_sessions' %}">
<span>Active Sessions</span> <span>Active Sessions</span>
</a> </a>
{% if show_mfa %}
<a class="btn" href="{% url 'bid_main:mfa' %}"> <a class="btn" href="{% url 'bid_main:mfa' %}">
<span>Multi-factor Authentication</span> <span>Multi-factor Authentication</span>
</a> </a>
{% endif %}
</div> </div>
<div class="btn-row-fluid mt-3"> <div class="btn-row-fluid mt-3">
<a class="btn" href="{% url 'bid_main:password_change' %}"> <a class="btn" href="{% url 'bid_main:password_change' %}">

View File

@ -67,14 +67,20 @@ class IndexView(mixins.MfaRequiredIfConfiguredMixin, mixins.PageIdMixin, Templat
name for name, roles in self.BID_APP_TO_ROLES.items() if roles.intersection(role_names) name for name, roles in self.BID_APP_TO_ROLES.items() if roles.intersection(role_names)
} }
show_mfa = (
user.mfa_devices_per_type
or (user.email.endswith('@blender.org') and user.confirmed_email_at)
)
return { return {
**super().get_context_data(**kwargs), **super().get_context_data(**kwargs),
"apps": apps, "apps": apps,
"cloud_needs_renewal": ( "cloud_needs_renewal": (
"cloud_has_subscription" in role_names and "cloud_subscriber" not in role_names "cloud_has_subscription" in role_names and "cloud_subscriber" not in role_names
), ),
"show_confirm_address": not user.has_confirmed_email,
"private_badge_ids": {role.id for role in user.private_badges.all()}, "private_badge_ids": {role.id for role in user.private_badges.all()},
"show_confirm_address": not user.has_confirmed_email,
"show_mfa": show_mfa,
} }