Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
46ebe245
Unverified
Commit
46ebe245
authored
Nov 11, 2018
by
Torkel Ödegaard
Committed by
GitHub
Nov 11, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13999 from roidelapluie/originreferer
Remove Origin and Referer while proxying requests
parents
057696a0
62417ca6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletions
+14
-1
pkg/api/pluginproxy/ds_proxy.go
+4
-0
pkg/api/pluginproxy/ds_proxy_test.go
+10
-1
No files found.
pkg/api/pluginproxy/ds_proxy.go
View file @
46ebe245
...
...
@@ -195,6 +195,10 @@ func (proxy *DataSourceProxy) getDirector() func(req *http.Request) {
req
.
Header
.
Del
(
"X-Forwarded-Proto"
)
req
.
Header
.
Set
(
"User-Agent"
,
fmt
.
Sprintf
(
"Grafana/%s"
,
setting
.
BuildVersion
))
// Clear Origin and Referer to avoir CORS issues
req
.
Header
.
Del
(
"Origin"
)
req
.
Header
.
Del
(
"Referer"
)
// set X-Forwarded-For header
if
req
.
RemoteAddr
!=
""
{
remoteAddr
,
_
,
err
:=
net
.
SplitHostPort
(
req
.
RemoteAddr
)
...
...
pkg/api/pluginproxy/ds_proxy_test.go
View file @
46ebe245
...
...
@@ -371,13 +371,22 @@ func TestDSRouteRule(t *testing.T) {
ctx
:=
&
m
.
ReqContext
{}
proxy
:=
NewDataSourceProxy
(
ds
,
plugin
,
ctx
,
"/path/to/folder/"
)
req
,
err
:=
http
.
NewRequest
(
http
.
MethodGet
,
"http://grafana.com/sub"
,
nil
)
req
.
Header
.
Add
(
"Origin"
,
"grafana.com"
)
req
.
Header
.
Add
(
"Referer"
,
"grafana.com"
)
req
.
Header
.
Add
(
"X-Canary"
,
"stillthere"
)
So
(
err
,
ShouldBeNil
)
proxy
.
getDirector
()(
req
)
Convey
(
"Shou
dl
keep user request (including trailing slash)"
,
func
()
{
Convey
(
"Shou
ld
keep user request (including trailing slash)"
,
func
()
{
So
(
req
.
URL
.
String
(),
ShouldEqual
,
"http://host/root/path/to/folder/"
)
})
Convey
(
"Origin and Referer headers should be dropped"
,
func
()
{
So
(
req
.
Header
.
Get
(
"Origin"
),
ShouldEqual
,
""
)
So
(
req
.
Header
.
Get
(
"Referer"
),
ShouldEqual
,
""
)
So
(
req
.
Header
.
Get
(
"X-Canary"
),
ShouldEqual
,
"stillthere"
)
})
})
})
}
...
...
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