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
proto3
Commits
3b50185d
Commit
3b50185d
authored
Mar 16, 2018
by
Robin Sonnabend
Browse files
Use hmac.compare_digest for csrf token comparison
parent
c881adf3
Changes
1
Hide whitespace changes
Inline
Side-by-side
decorators.py
View file @
3b50185d
from
flask
import
request
,
flash
,
abort
from
functools
import
wraps
from
hmac
import
compare_digest
from
models.database
import
ALL_MODELS
from
shared
import
current_user
...
...
@@ -97,8 +98,8 @@ def protect_csrf(function):
@
wraps
(
function
)
def
_decorated_function
(
*
args
,
**
kwargs
):
token
=
request
.
args
.
get
(
"csrf_token"
)
if
token
!
=
get_csrf_token
()
:
prin
t
(
token
,
get_csrf
_token
()
)
true_
token
=
get_csrf_token
()
if
token
is
None
or
not
compare_diges
t
(
token
,
true
_token
)
:
abort
(
400
)
return
function
(
*
args
,
**
kwargs
)
return
_decorated_function
Write
Preview
Supports
Markdown
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