Skip to content
Snippets Groups Projects
Commit f8939ef5 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Add static user backend for testing purposes

parent 6c92b00d
Branches
No related tags found
No related merge requests found
......@@ -135,6 +135,30 @@ class ADManager:
for result in reader.search():
yield result.name.value
class StaticUserManager:
def __init__(self, users):
self.passwords = {
username: password
for (username, password, groups) in users
}
self.groups = {
username: groups
for (username, password, groups) in users
}
def authenticate(self, username, password):
return (username in self.passwords
and self.passwords[username] == password)
def groups(self, username, password=None):
if username in self.groups:
yield from self.groups[username]
def all_groups(self):
return list(set(group for group in groups.values()))
class SecurityManager:
def __init__(self, key, max_duration=300):
self.maccer = hmac.new(key.encode("utf-8"), digestmod=hashlib.sha512)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment