mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 07:27:04 +00:00
add setting ENABLE_FORCE_2FA_TO_ALL_USERS (#4070)
This commit is contained in:
@@ -759,6 +759,7 @@ CLOUD_DEMO_USER = 'demo@seafile.com'
|
|||||||
ENABLE_TWO_FACTOR_AUTH = False
|
ENABLE_TWO_FACTOR_AUTH = False
|
||||||
OTP_LOGIN_URL = '/profile/two_factor_authentication/setup/'
|
OTP_LOGIN_URL = '/profile/two_factor_authentication/setup/'
|
||||||
TWO_FACTOR_DEVICE_REMEMBER_DAYS = 90
|
TWO_FACTOR_DEVICE_REMEMBER_DAYS = 90
|
||||||
|
ENABLE_FORCE_2FA_TO_ALL_USERS = False
|
||||||
|
|
||||||
# Enable personal wiki, group wiki
|
# Enable personal wiki, group wiki
|
||||||
ENABLE_WIKI = True
|
ENABLE_WIKI = True
|
||||||
|
@@ -9,7 +9,7 @@ from django.http import HttpResponseRedirect
|
|||||||
from . import DEVICE_ID_SESSION_KEY
|
from . import DEVICE_ID_SESSION_KEY
|
||||||
from .models import Device
|
from .models import Device
|
||||||
from seahub.options.models import UserOptions
|
from seahub.options.models import UserOptions
|
||||||
from seahub.settings import SITE_ROOT
|
from seahub.settings import SITE_ROOT, ENABLE_FORCE_2FA_TO_ALL_USERS
|
||||||
|
|
||||||
|
|
||||||
class IsVerified(object):
|
class IsVerified(object):
|
||||||
@@ -85,10 +85,11 @@ class ForceTwoFactorAuthMiddleware(object):
|
|||||||
if not self.filter_request(request):
|
if not self.filter_request(request):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if not UserOptions.objects.is_force_2fa(user.username):
|
|
||||||
return None
|
|
||||||
|
|
||||||
if user.otp_device is not None:
|
if user.otp_device is not None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return HttpResponseRedirect(reverse('two_factor:setup'))
|
if ENABLE_FORCE_2FA_TO_ALL_USERS or UserOptions.objects.is_force_2fa(user.username):
|
||||||
|
return HttpResponseRedirect(reverse('two_factor:setup'))
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user