[Update] 调整MFA绑定策略 V2

This commit is contained in:
xinwen
2020-06-22 17:04:07 +08:00
parent 005573b53b
commit 3e993fd044
5 changed files with 53 additions and 44 deletions

View File

@@ -5,8 +5,8 @@ import re
import pyotp
import base64
import logging
import time
from django.http import Http404
from django.conf import settings
from django.utils.translation import ugettext as _
from django.core.cache import cache
@@ -333,3 +333,15 @@ def get_source_choices():
if settings.AUTH_CAS:
choices.append((User.SOURCE_CAS, choices_all[User.SOURCE_CAS]))
return choices
def is_auth_time_valid(session, key):
return True if session.get(key, 0) > time.time() else False
def is_auth_password_time_valid(session):
return is_auth_time_valid(session, 'auth_password_expired_at')
def is_auth_otp_time_valid(session):
return is_auth_time_valid(session, 'auth_opt_expired_at')