otp issuer配置项 (#2133)

多机房环境中otp issuer配置
pull/2197/head
Titan 6 years ago committed by 老广
parent 3d13f3a17d
commit 2833f343b2

@ -354,6 +354,9 @@ AUTH_USER_MODEL = 'users.User'
FILE_UPLOAD_PERMISSIONS = 0o644
FILE_UPLOAD_DIRECTORY_PERMISSIONS = 0o755
# OTP settings
OTP_ISSUER_NAME = CONFIG.OTP_ISSUER_NAME
# Auth LDAP settings
AUTH_LDAP = False
AUTH_LDAP_SERVER_URI = 'ldap://localhost:389'

@ -284,7 +284,8 @@ def generate_otp_uri(request, issuer="Jumpserver"):
otp_secret_key = base64.b32encode(os.urandom(10)).decode('utf-8')
cache.set(request.session.session_key+'otp_key', otp_secret_key, 600)
totp = pyotp.TOTP(otp_secret_key)
return totp.provisioning_uri(name=user.username, issuer_name=issuer), otp_secret_key
otp_issuer_name = settings.OTP_ISSUER_NAME or issuer
return totp.provisioning_uri(name=user.username, issuer_name=otp_issuer_name), otp_secret_key
def check_otp_code(otp_secret_key, otp_code):

Loading…
Cancel
Save