Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
erp5
Commits
35bffe85
Commit
35bffe85
authored
Nov 17, 2016
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Security: JWT always set CORS Headers
parent
06f21399
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletion
+18
-1
product/ERP5Security/ERP5JSONWebTokenPlugin.py
product/ERP5Security/ERP5JSONWebTokenPlugin.py
+18
-1
No files found.
product/ERP5Security/ERP5JSONWebTokenPlugin.py
View file @
35bffe85
...
@@ -113,8 +113,9 @@ class ERP5JSONWebTokenPlugin(BasePlugin):
...
@@ -113,8 +113,9 @@ class ERP5JSONWebTokenPlugin(BasePlugin):
if
login_pw
is
not
None
:
if
login_pw
is
not
None
:
creds
[
'login'
],
creds
[
'password'
]
=
login_pw
creds
[
'login'
],
creds
[
'password'
]
=
login_pw
else
:
else
:
# SameSite Policy is implemented serverside
origin
=
request
.
getHeader
(
"Origin"
,
None
)
origin
=
request
.
getHeader
(
"Origin"
,
None
)
# SameSite Policy is implemented serverside
if
origin
is
None
:
if
origin
is
None
:
referer_url
=
request
.
getHeader
(
"Referer"
,
None
)
referer_url
=
request
.
getHeader
(
"Referer"
,
None
)
if
referer_url
is
not
None
:
if
referer_url
is
not
None
:
...
@@ -127,6 +128,22 @@ class ERP5JSONWebTokenPlugin(BasePlugin):
...
@@ -127,6 +128,22 @@ class ERP5JSONWebTokenPlugin(BasePlugin):
cookie
=
self
.
same_site_cookie
cookie
=
self
.
same_site_cookie
origin
=
None
origin
=
None
else
:
else
:
# Always allow CORS when credentials are not in the request
request
.
response
.
setHeader
(
"Access-Control-Allow-Credentials"
,
"true"
)
request
.
response
.
setHeader
(
"Access-Control-Allow-Headers"
,
"Origin, X-Requested-With, Content-Type, Accept"
)
request
.
response
.
setHeader
(
"Access-Control-Allow-Methods"
,
"GET, OPTIONS, HEAD, DELETE, PUT, POST"
)
request
.
response
.
setHeader
(
"Access-Control-Allow-Origin"
,
origin
)
request
.
response
.
setHeader
(
"Access-Control-Expose-Headers"
,
"Content-Type, Content-Length, WWW-Authenticate, X-Location"
)
# For CORS use a different token
cookie
=
self
.
cors_cookie
cookie
=
self
.
cors_cookie
token
=
request
.
cookies
.
get
(
cookie
)
token
=
request
.
cookies
.
get
(
cookie
)
...
...
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