Browse Source

feat[__init__.py]: add cache entry drop if password is wrong

pull/2/head
Dennis Buchhorn 9 months ago
parent
commit
a9ce7687d1
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      radicale-auth-ldap/__init__.py

+ 9
- 1
radicale-auth-ldap/__init__.py View File

@ -84,8 +84,16 @@ class UserCache:
hashedUserName = hashlib.sha256((userName + self.salt).encode()).hexdigest() hashedUserName = hashlib.sha256((userName + self.salt).encode()).hexdigest()
hashedPassword = hashlib.sha256((password + self.salt).encode()).hexdigest() hashedPassword = hashlib.sha256((password + self.salt).encode()).hexdigest()
## Check if user is in cache
if hashedUserName in self.cache: if hashedUserName in self.cache:
return self.cache[hashedUserName].checkSecret(hashedPassword)
## Check if user password is correct
if self.cache[hashedUserName].checkSecret(hashedPassword):
return True
else
## Delete cache entry if password is wrong
self.cache.pop(hashedUserName)
return False
else: else:
return False return False


Loading…
Cancel
Save