1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-02 07:47:32 +00:00

add setting ENABLE_FORCE_2FA_TO_ALL_USERS (#4070)

This commit is contained in:
Leo 2019-09-09 16:12:05 +08:00 committed by Daniel Pan
parent 0232b5cfb5
commit 3fa9f80432
2 changed files with 7 additions and 5 deletions

View File

@ -759,6 +759,7 @@ CLOUD_DEMO_USER = 'demo@seafile.com'
ENABLE_TWO_FACTOR_AUTH = False
OTP_LOGIN_URL = '/profile/two_factor_authentication/setup/'
TWO_FACTOR_DEVICE_REMEMBER_DAYS = 90
ENABLE_FORCE_2FA_TO_ALL_USERS = False
# Enable personal wiki, group wiki
ENABLE_WIKI = True

View File

@ -9,7 +9,7 @@ from django.http import HttpResponseRedirect
from . import DEVICE_ID_SESSION_KEY
from .models import Device
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):
@ -85,10 +85,11 @@ class ForceTwoFactorAuthMiddleware(object):
if not self.filter_request(request):
return None
if not UserOptions.objects.is_force_2fa(user.username):
return None
if user.otp_device is not 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