Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
2797c94c
Commit
2797c94c
authored
Sep 18, 2016
by
Serge S. Koval
Committed by
GitHub
Sep 18, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1346 from ei-grad/production-csrf-fix
Fix CSRF for production deployments
parents
d897c718
db21a600
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
__init__.py
flask_admin/form/__init__.py
+10
-2
No files found.
flask_admin/form/__init__.py
View file @
2797c94c
...
...
@@ -43,8 +43,9 @@ def recreate_field(unbound):
if
int
(
wtforms_version
[
0
])
>
1
:
# only WTForms 2+ has built-in CSRF functionality
from
os
import
urandom
from
flask
import
session
from
flask
import
session
,
current_app
from
wtforms.csrf.session
import
SessionCSRF
from
flask_admin._compat
import
text_type
class
SecureForm
(
BaseForm
):
"""
...
...
@@ -55,7 +56,14 @@ if int(wtforms_version[0]) > 1:
class
Meta
:
csrf
=
True
csrf_class
=
SessionCSRF
csrf_secret
=
urandom
(
24
)
_csrf_secret
=
urandom
(
24
)
@
property
def
csrf_secret
(
self
):
secret
=
current_app
.
secret_key
or
self
.
_csrf_secret
if
isinstance
(
secret
,
text_type
):
secret
=
secret
.
encode
(
'utf-8'
)
return
secret
@
property
def
csrf_context
(
self
):
...
...
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