Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
2833f343
Commit
2833f343
authored
Dec 10, 2018
by
Titan
Committed by
老广
Dec 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
otp issuer配置项 (#2133)
多机房环境中otp issuer配置
parent
3d13f3a1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
1 deletion
+5
-1
settings.py
apps/jumpserver/settings.py
+3
-0
utils.py
apps/users/utils.py
+2
-1
No files found.
apps/jumpserver/settings.py
View file @
2833f343
...
@@ -354,6 +354,9 @@ AUTH_USER_MODEL = 'users.User'
...
@@ -354,6 +354,9 @@ AUTH_USER_MODEL = 'users.User'
FILE_UPLOAD_PERMISSIONS
=
0
o644
FILE_UPLOAD_PERMISSIONS
=
0
o644
FILE_UPLOAD_DIRECTORY_PERMISSIONS
=
0
o755
FILE_UPLOAD_DIRECTORY_PERMISSIONS
=
0
o755
# OTP settings
OTP_ISSUER_NAME
=
CONFIG
.
OTP_ISSUER_NAME
# Auth LDAP settings
# Auth LDAP settings
AUTH_LDAP
=
False
AUTH_LDAP
=
False
AUTH_LDAP_SERVER_URI
=
'ldap://localhost:389'
AUTH_LDAP_SERVER_URI
=
'ldap://localhost:389'
...
...
apps/users/utils.py
View file @
2833f343
...
@@ -284,7 +284,8 @@ def generate_otp_uri(request, issuer="Jumpserver"):
...
@@ -284,7 +284,8 @@ def generate_otp_uri(request, issuer="Jumpserver"):
otp_secret_key
=
base64
.
b32encode
(
os
.
urandom
(
10
))
.
decode
(
'utf-8'
)
otp_secret_key
=
base64
.
b32encode
(
os
.
urandom
(
10
))
.
decode
(
'utf-8'
)
cache
.
set
(
request
.
session
.
session_key
+
'otp_key'
,
otp_secret_key
,
600
)
cache
.
set
(
request
.
session
.
session_key
+
'otp_key'
,
otp_secret_key
,
600
)
totp
=
pyotp
.
TOTP
(
otp_secret_key
)
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
):
def
check_otp_code
(
otp_secret_key
,
otp_code
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment