Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
protokollsystem
common-web
Commits
2a0f8817
Commit
2a0f8817
authored
Apr 08, 2018
by
Robin Sonnabend
Browse files
Support bytes as SECURITY_KEY
parent
93d19c52
Changes
1
Hide whitespace changes
Inline
Side-by-side
auth.py
View file @
2a0f8817
...
...
@@ -59,7 +59,9 @@ class UserManager:
class
SecurityManager
:
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
def
hash_user
(
self
,
user
):
...
...
@@ -99,7 +101,7 @@ class StaticUserManager:
def
__repr__
(
self
):
users
=
[
(
username
,
self
.
passwords
[
username
],
self
.
group
s
[
username
])
(
username
,
self
.
passwords
[
username
],
self
.
group
_map
[
username
])
for
username
in
self
.
passwords
]
return
"StaticUserManager({})"
.
format
(
users
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment