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
cf7a4997
Commit
cf7a4997
authored
Oct 18, 2017
by
Robin Gustafsson
Committed by
Daniel Lee
Dec 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proxyds: delete cookies except those listed in keepCookies
parent
bcc85862
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
7 deletions
+20
-7
pkg/api/pluginproxy/ds_proxy.go
+17
-2
pkg/api/pluginproxy/ds_proxy_test.go
+3
-5
No files found.
pkg/api/pluginproxy/ds_proxy.go
View file @
cf7a4997
...
...
@@ -135,9 +135,24 @@ func (proxy *DataSourceProxy) getDirector() func(req *http.Request) {
req
.
Header
.
Add
(
"Authorization"
,
dsAuth
)
}
// clear cookie headers
// clear cookie header, except for whitelisted cookies
var
keptCookies
[]
*
http
.
Cookie
if
proxy
.
ds
.
JsonData
!=
nil
{
if
keepCookies
:=
proxy
.
ds
.
JsonData
.
Get
(
"keepCookies"
);
keepCookies
!=
nil
{
keepCookieNames
:=
keepCookies
.
MustStringArray
()
for
_
,
c
:=
range
req
.
Cookies
()
{
for
_
,
v
:=
range
keepCookieNames
{
if
c
.
Name
==
v
{
keptCookies
=
append
(
keptCookies
,
c
)
}
}
}
}
}
req
.
Header
.
Del
(
"Cookie"
)
req
.
Header
.
Del
(
"Set-Cookie"
)
for
_
,
c
:=
range
keptCookies
{
req
.
AddCookie
(
c
)
}
// clear X-Forwarded Host/Port/Proto headers
req
.
Header
.
Del
(
"X-Forwarded-Host"
)
...
...
pkg/api/pluginproxy/ds_proxy_test.go
View file @
cf7a4997
...
...
@@ -152,8 +152,7 @@ func TestDSRouteRule(t *testing.T) {
Convey
(
"When proxying a data source with no keepCookies specified"
,
func
()
{
plugin
:=
&
plugins
.
DataSourcePlugin
{}
json
:=
simplejson
.
New
()
json
.
Set
(
"keepCookies"
,
[]
string
{})
json
,
_
:=
simplejson
.
NewJson
([]
byte
(
`{"keepCookies": []}`
))
ds
:=
&
m
.
DataSource
{
Type
:
m
.
DS_GRAPHITE
,
...
...
@@ -179,8 +178,7 @@ func TestDSRouteRule(t *testing.T) {
Convey
(
"When proxying a data source with keep cookies specified"
,
func
()
{
plugin
:=
&
plugins
.
DataSourcePlugin
{}
json
:=
simplejson
.
New
()
json
.
Set
(
"keepCookies"
,
[]
string
{
"JSESSION_ID"
})
json
,
_
:=
simplejson
.
NewJson
([]
byte
(
`{"keepCookies": ["JSESSION_ID"]}`
))
ds
:=
&
m
.
DataSource
{
Type
:
m
.
DS_GRAPHITE
,
...
...
@@ -199,7 +197,7 @@ func TestDSRouteRule(t *testing.T) {
proxy
.
getDirector
()(
&
req
)
Convey
(
"Should keep named cookies"
,
func
()
{
So
(
req
.
Header
.
Get
(
"Cookie"
),
ShouldEqual
,
"JSESSION=test"
)
So
(
req
.
Header
.
Get
(
"Cookie"
),
ShouldEqual
,
"JSESSION
_ID
=test"
)
})
})
...
...
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