mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
add SSHA password hasher
This commit is contained in:
@@ -7,7 +7,7 @@ from django.utils.encoding import smart_text
|
||||
|
||||
from modoboa.core.password_hashers.advanced import ( # NOQA:F401
|
||||
BLFCRYPTHasher, MD5CRYPTHasher, SHA256CRYPTHasher, SHA512CRYPTHasher,
|
||||
ARGON2IDHasher
|
||||
ARGON2IDHasher, SSHAHasher
|
||||
)
|
||||
from modoboa.core.password_hashers.base import ( # NOQA:F401
|
||||
CRYPTHasher, MD5Hasher, PLAINHasher, SHA256Hasher
|
||||
|
||||
@@ -113,6 +113,25 @@ class SHA512CRYPTHasher(PasswordHasher):
|
||||
return sha512_crypt.verify(clearvalue, hashed_value)
|
||||
|
||||
|
||||
class SSHAHasher(PasswordHasher):
|
||||
"""
|
||||
Salted SHA1 password hasher.
|
||||
"""
|
||||
_weak = True
|
||||
|
||||
@property
|
||||
def scheme(self):
|
||||
return "{SSHA}"
|
||||
|
||||
def _encrypt(self, clearvalue, salt=None):
|
||||
# We have to remove the {SSHA} at the beginning of the string
|
||||
return ldap_salted_sha1.hash(clearvalue)[6:]
|
||||
|
||||
def verify(self, clearvalue, hashed_value):
|
||||
# We have to add the scheme for the hashed_value to be validated
|
||||
return ldap_salted_sha1.verify(clearvalue, f'{{SSHA}}{hashed_value}')
|
||||
|
||||
|
||||
if argon2_hasher is not None:
|
||||
class ARGON2IDHasher(PasswordHasher):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user