mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
added setting to anable MFA
This commit is contained in:
parent
a8e18a7972
commit
9d68d6bdca
@ -11,6 +11,7 @@ from rest_framework.authtoken.models import Token
|
|||||||
from allauth_2fa.middleware import BaseRequire2FAMiddleware, AllauthTwoFactorMiddleware
|
from allauth_2fa.middleware import BaseRequire2FAMiddleware, AllauthTwoFactorMiddleware
|
||||||
|
|
||||||
from InvenTree.urls import frontendpatterns
|
from InvenTree.urls import frontendpatterns
|
||||||
|
from common.models import InvenTreeSetting
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger("inventree")
|
logger = logging.getLogger("inventree")
|
||||||
@ -162,7 +163,7 @@ class Check2FAMiddleware(BaseRequire2FAMiddleware):
|
|||||||
# Superusers are require to have 2FA.
|
# Superusers are require to have 2FA.
|
||||||
try:
|
try:
|
||||||
if url_matcher.resolve(request.path[1:]):
|
if url_matcher.resolve(request.path[1:]):
|
||||||
return True
|
return InvenTreeSetting.get_setting('LOGIN_ENFORCE_MFA')
|
||||||
except Resolver404:
|
except Resolver404:
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
@ -853,6 +853,12 @@ class InvenTreeSetting(BaseInvenTreeSetting):
|
|||||||
'default': '',
|
'default': '',
|
||||||
'choices': settings_group_options
|
'choices': settings_group_options
|
||||||
},
|
},
|
||||||
|
'LOGIN_ENFORCE_MFA': {
|
||||||
|
'name': _('Enforce MFA'),
|
||||||
|
'description': _('Users must use multifaktor security.'),
|
||||||
|
'default': False,
|
||||||
|
'validator': bool,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
{% include "InvenTree/settings/setting.html" with key="LOGIN_ENABLE_SSO" icon="fa-info-circle" %}
|
{% include "InvenTree/settings/setting.html" with key="LOGIN_ENABLE_SSO" icon="fa-info-circle" %}
|
||||||
{% include "InvenTree/settings/setting.html" with key="LOGIN_ENABLE_PWD_FORGOT" icon="fa-info-circle" %}
|
{% include "InvenTree/settings/setting.html" with key="LOGIN_ENABLE_PWD_FORGOT" icon="fa-info-circle" %}
|
||||||
{% include "InvenTree/settings/setting.html" with key="LOGIN_MAIL_REQUIRED" icon="fa-info-circle" %}
|
{% include "InvenTree/settings/setting.html" with key="LOGIN_MAIL_REQUIRED" icon="fa-info-circle" %}
|
||||||
|
{% include "InvenTree/settings/setting.html" with key="LOGIN_ENFORCE_MFA" %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{% trans 'Signup' %}</td>
|
<td>{% trans 'Signup' %}</td>
|
||||||
<td colspan='4'></td>
|
<td colspan='4'></td>
|
||||||
|
Loading…
Reference in New Issue
Block a user