Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
B.I.T.S. Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
B.I.T.S. 4.0
B.I.T.S. Server
Commits
892c6595
Commit
892c6595
authored
Feb 25, 2019
by
JackV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace passlib with built-in crypt
parent
1021869d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
10 deletions
+9
-10
bitsd/server/auth.py
bitsd/server/auth.py
+8
-7
requirements.txt
requirements.txt
+0
-1
setup.py
setup.py
+1
-2
No files found.
bitsd/server/auth.py
View file @
892c6595
...
...
@@ -6,8 +6,8 @@
# GNU GPLv3. See COPYING at top level for more information.
#
from
datetime
import
datetime
,
timedelta
import
crypt
from
passlib.hash
import
sha512_crypt
as
Hasher
from
tornado.options
import
options
from
bitsd.persistence.query
import
get_user
,
get_last_login_attempt
,
log_last_login_attempt
...
...
@@ -70,19 +70,20 @@ def verify(session, username, supplied_password, ip_address):
if
user
is
None
:
LOG
.
warn
(
"Failed attempt for non existent user %r"
,
username
)
# Calculate hash anyway (see docs for the explanation)
Hasher
.
encrypt
(
supplied_password
)
crypt
.
crypt
(
supplied_password
,
crypt
.
mksalt
(
rounds
=
656000
)
)
log_last_login_attempt
(
session
,
ip_address
,
username
)
return
False
else
:
valid
=
Hasher
.
verify
(
supplied_password
,
user
.
password
)
if
not
valid
:
new_pw
=
crypt
.
crypt
(
supplied_password
,
user
.
password
)
if
not
user
.
password
==
new_pw
:
log_last_login_attempt
(
session
,
ip_address
,
username
)
return
valid
else
:
return
True
def
useradd
(
session
,
username
,
password
):
"""Add user with hashed password to database"""
user
=
User
(
username
,
Hasher
.
encrypt
(
password
))
user
=
User
(
username
,
crypt
.
crypt
(
password
,
crypt
.
mksalt
(
rounds
=
656000
)
))
persist
(
session
,
user
)
...
...
@@ -95,5 +96,5 @@ def userdel(session, username):
def
usermod
(
session
,
username
,
password
):
""""Modify password for existing user."""
user
=
get_user
(
session
,
username
)
user
.
password
=
Hasher
.
encrypt
(
password
)
user
.
password
=
crypt
.
crypt
(
password
,
crypt
.
mksalt
(
rounds
=
656000
)
)
persist
(
session
,
user
)
requirements.txt
View file @
892c6595
futures
passlib
markdown
sqlalchemy
>=0.7
tornado
==4.*
setup.py
View file @
892c6595
...
...
@@ -22,8 +22,7 @@ setup(
'sqlalchemy >= 0.7'
,
'markdown'
,
'futures'
,
'pycares'
,
'passlib'
'pycares'
],
packages
=
[
'bitsd'
,
...
...
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