Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Nounous
re2o
Commits
382398a3
Commit
382398a3
authored
Aug 10, 2018
by
Charlie Jacomme
Committed by
chirac
Aug 12, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Produce newer hash upon login
parent
a55a6b30
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
re2o/login.py
re2o/login.py
+17
-0
re2o/settings.py
re2o/settings.py
+3
-0
No files found.
re2o/login.py
View file @
382398a3
...
...
@@ -35,6 +35,7 @@ import os
from
base64
import
encodestring
,
decodestring
,
b64encode
,
b64decode
from
collections
import
OrderedDict
from
django.contrib.auth
import
hashers
from
django.contrib.auth.backends
import
ModelBackend
from
hmac
import
compare_digest
as
constant_time_compare
...
...
@@ -226,3 +227,19 @@ class SSHAPasswordHasher(hashers.BasePasswordHasher):
As we are not using multiple iterations the method is pretty useless
"""
pass
class
RecryptBackend
(
ModelBackend
):
def
authenticate
(
self
,
username
=
None
,
password
=
None
):
# we obtain from the classical auth backend the user
user
=
super
(
RecryptBackend
,
self
).
authenticate
(
username
,
password
)
if
user
:
if
not
(
user
.
pwd_ntlm
):
# if we dont have NT hash, we create it
user
.
pwd_ntlm
=
hashNT
(
password
)
user
.
save
()
if
not
(
"SSHA"
in
user
.
password
):
# if the hash is too old, we update it
user
.
password
=
makeSecret
(
password
)
user
.
save
()
return
user
re2o/settings.py
View file @
382398a3
...
...
@@ -96,6 +96,9 @@ MIDDLEWARE_CLASSES = (
'django.middleware.security.SecurityMiddleware'
,
'reversion.middleware.RevisionMiddleware'
,
)
AUTHENTICATION_BACKENDS
=
[
're2o.login.RecryptBackend'
]
# Include debug_toolbar middleware if activated
if
'debug_toolbar'
in
INSTALLED_APPS
:
# Include this middleware at the beggining
...
...
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