Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nk20
Manage
Activity
Members
Labels
Plan
Issues
31
Issue boards
Milestones
Wiki
Code
Merge requests
5
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BDE
nk20
Commits
efe32e45
Commit
efe32e45
authored
5 years ago
by
Pierre-antoine Comby
Browse files
Options
Downloads
Plain Diff
Merge branch 'import_nk15' of gitlab.crans.org:bde/nk20 into import_nk15
parents
f47d803a
8feb2ec5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!19
Import nk15
Pipeline
#7780
passed with warnings with stages
in 3 minutes and 49 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/member/hashers.py
+27
-0
27 additions, 0 deletions
apps/member/hashers.py
note_kfet/settings/base.py
+6
-0
6 additions, 0 deletions
note_kfet/settings/base.py
with
33 additions
and
0 deletions
apps/member/hashers.py
0 → 100644
+
27
−
0
View file @
efe32e45
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
import
hashlib
from
django.contrib.auth.hashers
import
PBKDF2PasswordHasher
from
django.utils.crypto
import
constant_time_compare
class
CustomNK15Hasher
(
PBKDF2PasswordHasher
):
"""
Permet d
'
importer les mots de passe depuis la Note KFet 2015.
Si un hash de mot de passe est de la forme :
`custom_nk15$<NB>$<ENCODED>`
où <NB> est un entier quelconque (symbolisant normalement un nombre d
'
itérations)
et <ENCODED> le hash du mot de passe dans la Note Kfet 2015,
alors ce hasher va vérifier le mot de passe.
N
'
ayant pas la priorité (cf note_kfet/settings/base.py), le mot de passe sera
converti automatiquement avec l
'
algorithme PBKDF2.
"""
algorithm
=
"
custom_nk15
"
def
verify
(
self
,
password
,
encoded
):
if
'
|
'
in
encoded
:
salt
,
db_hashed_pass
=
encoded
.
split
(
'
$
'
)[
2
].
split
(
'
|
'
)
return
constant_time_compare
(
hashlib
.
sha256
((
salt
+
password
).
encode
(
"
utf-8
"
)).
hexdigest
(),
db_hashed_pass
)
return
super
().
verify
(
password
,
encoded
)
This diff is collapsed.
Click to expand it.
note_kfet/settings/base.py
+
6
−
0
View file @
efe32e45
...
...
@@ -117,6 +117,12 @@ AUTH_PASSWORD_VALIDATORS = [
},
]
# Use our custom hasher in order to import NK15 passwords
PASSWORD_HASHERS
=
[
'
django.contrib.auth.hashers.PBKDF2PasswordHasher
'
,
'
member.hashers.CustomNK15Hasher
'
,
]
# Django Guardian object permissions
AUTHENTICATION_BACKENDS
=
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment