51 Commits

Author SHA1 Message Date
e210725d3d DataProxy: Restore Set-Cookie header after proxy request (#16838)
If Grafana rotates the user's auth token during a request to the data 
source proxy it will set the Set-Cookie header with new auth token in 
response before proxying the request to the datasource.
Before this fix the Set-Cookie response header was cleared after the 
proxied request was finished to make sure that proxied datasources 
cannot affect cookies in users browsers. This had the consequence 
of accidentally also clearing the new auth token set in Set-Cookie 
header.
With this fix the original Set-Cookie value in response header is now 
restored after the proxied datasource request is finished. The existing
logic of clearing Set-Cookie response header from proxied request 
have been left intact.

Fixes #16757
2019-05-01 16:32:03 +02:00
66f6e16916 Security: Store datasource passwords encrypted in secureJsonData (#16175)
* Store passwords in secureJsonData

* Revert unnecessary refactors

* Fix for nil jsonSecureData value

* Remove copied encryption code from migration

* Fix wrong field reference

* Remove migration and provisioning changes

* Use password getters in datasource proxy

* Refactor password handling in datasource configs

* Add provisioning warnings

* Update documentation

* Remove migration command, moved to separate PR

* Remove unused code

* Set the upgrade version

* Remove unused code

* Remove double reference
2019-04-15 11:11:17 +02:00
b696492891 Rename dispatched commands to make them easy to grok 2019-03-20 14:32:41 -04:00
3f9a19dcd5 Merge branch 'master' into 12556-oauth-pass-thru 2019-03-14 13:18:00 -04:00
697a87b7b2 Add check so that header is not sent for anonymous users 2019-03-14 16:33:21 +01:00
bbdc1c0e64 Add custom header with grafana user and a config switch for it 2019-03-14 16:33:19 +01:00
8d8119aa98 Change import path for social since it has moved 2019-03-13 14:34:55 -04:00
8d19ca005f Merge branch 'master' into 12556-oauth-pass-thru 2019-03-13 14:25:43 -04:00
7e62394d01 Add function in ds_proxy to handle oauthPassThru headers 2019-03-13 13:45:32 -04:00
3b15e110a5 Get most recent oauth token from db, rather than lookup by auth_module 2019-03-13 13:22:22 -04:00
a1cd550df4 revert ds_proxy timeout and implement dataproxy timeout correctly 2019-02-11 13:42:05 +01:00
5a59cdf0ef Add oauth pass-thru option for datasources 2019-02-01 19:40:57 -05:00
8261613b51 pkg/util/{ip.go,url.go}: Fix some golint issues
See,
$ gometalinter --vendor --deadline 10m --disable-all --enable=golint  ./...
ip.go:8:6⚠️ func SplitIpPort should be SplitIPPort (golint)
url.go:14:6⚠️ func NewUrlQueryReader should be NewURLQueryReader (golint)
url.go:9:6⚠️ type UrlQueryReader should be URLQueryReader (golint)
url.go:37:6⚠️ func JoinUrlFragments should be JoinURLFragments (golint)
2019-01-28 22:29:20 +01:00
9108fd1b9d add global datasource proxy timeout setting
closes grafana#5699
2019-01-24 14:06:48 -05:00
62417ca69f Remove Origin and Referer headers while proxying requests
Fix #13949
Fix #13328

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2018-11-08 14:57:47 +01:00
56e8e50497 Stackdriver: Use ds_auth_provider in stackdriver. This will make sure the token is renewed when it has exporired 2018-09-14 09:38:16 +02:00
6a610558c4 Stackdriver: Start breaking out apply route to its own file 2018-09-14 09:38:16 +02:00
23339e4322 Stackdriver: Use new access token API 2018-09-14 09:35:28 +02:00
e7648c4070 dsproxy: implements support for plugin routes with jwt file
Google Cloud service accounts use a JWT token to get an
oauth access token. This adds support for that.
2018-09-14 09:35:27 +02:00
a4ef4792bc Stackdriver: Add scope for google resource manager 2018-09-14 09:35:26 +02:00
350bcf4f56 Fixed broken if statement 2018-09-14 09:35:26 +02:00
7197a4c17f Adds jwt token signing google auth 2018-09-14 09:35:26 +02:00
ef3beb1f0e Adds poc code for retrieving google auth accesstoken 2018-09-14 09:33:50 +02:00
c75e071213 dsproxy: interpolate route url
Allows for dynamic urls for plugin routes. There are a few plugins
where the route url should be configurable and this change allows
using jsonData fields in the url field for a route in the
plugin.json file for a plugin.
2018-08-18 16:02:49 +02:00
13921902b5 Set User-Agent header in all proxied datasource requests
Header value will be Grafana/%version%, i.e. Grafana/5.3.0
2018-08-15 09:46:59 +02:00
2459b177f9 change: Set User-Agent to Grafana/%Version% Proxied-DS-Request %DS-Type% in all proxied ds requests 2018-08-13 18:09:01 +02:00
828fb39ee2 Merge pull request #11643 from mrsiano/generic_oauth
Pass configured/auth headers to a Datasource.
2018-06-21 14:21:59 +02:00
cc1e3a0e3c Pass configured/auth headers to a Datasource.
In some setups (ex openshift), the Datasource will require Grafana
to pass oauth token as header when sending queries.
Also, this PR allow to send any header which is something
Grafana currently does not support.
2018-06-21 14:58:05 +03:00
10d30f0b73 dsproxy: move http client variable back
After refactoring to be able to mock the client in
a test, the client wasn't a global variable anymore.
This change moves the client back to being a package-
level variable.
2018-06-14 13:39:46 +02:00
719ebdc24d dsproxy: allow multiple access tokens per datasource
Changes the cache key for tokens to cache on datasource id +
route path + http method instead of just datasource id.
2018-06-12 17:39:38 +02:00
9413ce5ef6 Merge pull request #8096 from ryantxu/influx-db-query2
let the influxdb API set a database
2018-04-13 18:22:12 +02:00
980e078222 Merge pull request #11326 from bergquist/more_traces
dataproxy: adds dashboardid and panelid as tags
2018-03-23 17:13:15 +01:00
0a415c50d0 Make golint happier 2018-03-22 22:38:44 +01:00
f142548969 dataproxy: adds dashboardid and panelid as tags
closes #11315
2018-03-20 22:23:28 +01:00
a04c4ba454 allow any database for influx proxy 2018-03-15 13:01:17 +01:00
ad88e5398c remove 2018-03-15 12:57:09 +01:00
4f8ee9f5a7 merge with master 2018-03-14 23:52:24 +01:00
a83ede0193 support POST for query and query_range 2018-03-12 13:25:05 +09:00
c0ecdee375 rename Context to ReqContext 2018-03-07 11:54:50 -05:00
338655dd37 move Context and session out of middleware 2018-03-06 18:16:49 -05:00
cf7a49977f proxyds: delete cookies except those listed in keepCookies 2017-12-14 11:46:44 +01:00
fb9c714a9a run go fmt 2017-10-18 23:49:33 +02:00
4440133f4d Add a setting to allow DB queries 2017-10-18 23:33:10 +02:00
4f5f38f41b remove old handler 2017-09-29 13:45:11 +09:00
ee2e4c6567 add trace headers for outgoing requests 2017-09-18 11:08:58 +02:00
3c8133aa4b add traces for datasource reverse proxy requests 2017-09-18 11:08:58 +02:00
71c22fdbff dataproxy: removed some logging, closes #9078 2017-08-24 11:18:06 +02:00
71c9582944 data source with token auth is starting to work, #9078 2017-08-24 11:07:37 +02:00
3c9798bec9 datasource-proxy: token exchange 2017-08-23 17:18:43 +02:00
8bf49c51b9 dataproxy: refactoring data source proxy to support route templates and wrote more tests for data proxy code, #9078 2017-08-23 10:52:31 +02:00