Commit 2a0f8817 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Support bytes as SECURITY_KEY

parent 93d19c52
...@@ -59,7 +59,9 @@ class UserManager: ...@@ -59,7 +59,9 @@ class UserManager:
class SecurityManager: class SecurityManager:
def __init__(self, key, max_duration=300): def __init__(self, key, max_duration=300):
self.maccer = hmac.new(key.encode("utf-8"), digestmod=hashlib.sha512) if isinstance(key, str):
key = key.encode("utf-8")
self.maccer = hmac.new(key, digestmod=hashlib.sha512)
self.max_duration = max_duration self.max_duration = max_duration
def hash_user(self, user): def hash_user(self, user):
...@@ -99,7 +101,7 @@ class StaticUserManager: ...@@ -99,7 +101,7 @@ class StaticUserManager:
def __repr__(self): def __repr__(self):
users = [ users = [
(username, self.passwords[username], self.groups[username]) (username, self.passwords[username], self.group_map[username])
for username in self.passwords for username in self.passwords
] ]
return "StaticUserManager({})".format(users) return "StaticUserManager({})".format(users)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment