Commit Graph

5292 Commits

Author SHA1 Message Date
Arve Knudsen
08f01a6c4f
pkg/bus: Check errors (#19748)
* pkg/bus: Check errors
* pkg/bus: Convert tests to testify
2019-10-14 17:23:31 +02:00
Marcus Olsson
428ca600c0
Chore: Refactor grafana-server (#19796)
* Rename GrafanaServerImpl to Server

* Make flag dependencies explicit

* Extract method for building service graph

* Document and clarify methods

* Rename HttpServer to HTTPServer
2019-10-14 14:18:22 +02:00
Arve Knudsen
0b1913af6f
pkg/plugins: Check errors (#19715)
* pkg/plugins: Check errors
2019-10-11 21:02:15 +02:00
Kyle Brandt
2c3c576ca6
fix: export Bus on search service (#19773)
fix pkg/services/search/service.go:52:3: s.bus undefined (type *SearchService has no field or method bus, but does have Bus)

fixes issue introduced by #19765
2019-10-11 11:46:44 -04:00
Marcus Olsson
60f86c3b9c
Chore: Refactor GoConvey into stdlib for search service (#19765)
* Refactor GoConvey into stdlib

* Fix review comments
2019-10-11 17:08:15 +02:00
Weeco
8cd93f0b88 Datasource: Add custom headers on alerting queries (#19508)
* Add custom headers on alerting queries

Reference issue #15381

Signed-off-by: Martin Schneppenheim <martin.schneppenheim@rewe-digital.com>

* Fix datasource transport tests

* Migrate decrypting header test to models pkg

* Check correct header

* Add HTTP transport test

Fixes #15381
2019-10-11 14:28:52 +02:00
Arve Knudsen
7349a6b96c
pkg/infra: Check errors (#19705)
* pkg/infra: Check errors

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* pkg/infra: Handle errors

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Update pkg/infra/usagestats/usage_stats.go

Co-Authored-By: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2019-10-10 16:42:11 +02:00
Arve Knudsen
fe8d0d27d2
pkg/components: Check errors (#19703)
* pkg/components: Check errors
2019-10-10 09:06:55 +02:00
Arve Knudsen
f7ad580356
pkg/login: Check errors (#19714)
* pkg/login: Check errors
* pkg/login: Introduce "login" logger

Co-Authored-By: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2019-10-09 12:57:44 +02:00
Arve Knudsen
b858a5f496
Don't truncate IPv6 addresses (#19573)
* Bugfix: Fix parsing of IPv6 addresses

Make sure that IPv6 addresses aren't truncated when parsing. Fixes #18924
* util: Change network address parsing funcs to return error
* pkg/api: Return NetworkAddress instead of host/port
2019-10-09 08:58:45 +02:00
oddlittlebird
8b064fc141 Docs: Update pkg\README.md (#19615)
* Update README.md

Grammar and spelling edits

* Update pkg/README.md

Co-Authored-By: Marcus Olsson <olsson.e.marcus@gmail.com>

* Update README.md

* Update README.md
2019-10-09 08:04:56 +02:00
Arve Knudsen
0a2d5e16dd
pkg/api: Check errors (#19657)
* pkg/api: Check errors
* pkg/api: Remove unused function HashEmail
2019-10-08 18:57:53 +02:00
Jon Gyllenswärd
606392b4c6 API: added dashboardId and slug in response after import (#19692) 2019-10-08 17:47:18 +02:00
Ben Patterson
9904e14f8e Alerting: Fix dates stored in local time when pausing alerts (#19525)
* Make tests more sensitive to timezone.

* Time stamps should use UTC for consistency.

* Test: Assert state is paused after pauseAllAlerts call.
2019-10-08 17:25:15 +03:00
Anthony Templeton
6c0b5163dd CloudWatch: Changes incorrect dimension wmlid to wlmid (#19679)
Fixes #19476
2019-10-07 23:47:07 +02:00
Chad Nedzlek
20faef8de5 AzureMonitor: Alerting for Azure Application Insights (#19381)
* Convert Azure Application Insights datasource to Go

Allows for alerting of Application Insights data source

Closes: #15153

* Fix timeGrainReset

* Default time interval for querys for alerts

* Fix a few rename related bugs

* Update readme to indicate App Insights alerting

* Fix typo and add tests to ensure migration is happening

* Address code review feedback (mostly typos and unintended changes)
2019-10-07 14:18:14 +02:00
Sriramajeyam
50acb37a17 Azure Monitor : Query more than 10 dimensions ( Fixes #17230 ) (#18693)
* Fixes #17230

* Resovled comments

* Resolved comments

* spell fix
2019-10-03 16:53:11 +02:00
Marcus Olsson
2fb301ccaf
Docs: Improve guides for contributing (#19575)
* Move style guides into contribute directory

* Move contribution guides into contribute directory

* Refactor CONTRIBUTING.md

* Clean up docs/README.md

* Update reference to style guide and minor formatting fixes

* Apply suggestions from code review

Co-Authored-By: gotjosh <josue.abreu@gmail.com>

* Update CONTRIBUTING.md

Co-Authored-By: gotjosh <josue.abreu@gmail.com>
2019-10-03 14:13:58 +02:00
Arve Knudsen
39d8e73412
Chore: Upgrade to Go 1.13 (#19502)
* Chore: Upgrade to Go 1.13

Fixes: #18878

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Chore: Upgrade lint tools in order to work with Go 1.13

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Chore: Fix Go linting issues

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2019-10-02 13:59:05 +02:00
gotjosh
8e508e5ce4 Provisioning: Handle empty nested keys on YAML provisioning datasources (#19547)
* Fix: Handle empty nested keys on YAML provisioning datasources

As we provision a datasource via a YAML file, we attempt to transform the
file into sensible Go types that the provisioning code can use.

While this happens, there is a chance some of the keys nested within
the YAML array are empty.

This fix allows the YAML parser to handle empty keys by null checking
the return of `reflect.TypeOf` which according to the documentation:

> TypeOf returns the reflection Type that represents the dynamic type of i. If i is a nil interface value, TypeOf returns nil.

Can return nil.

* Add tests
2019-10-02 08:48:19 +02:00
Sean Nessworthy
404bf2e0dd CloudWatch: Add ap-east-1 to hard-coded region lists (#19523)
* CloudWatch: Add ap-east-1 to hard-coded region lists (#17448)

* CloudWatch: Fix handleGetRegion tests
2019-10-01 14:23:43 +02:00
gotjosh
4181b30b75
API: Add createdAt and updatedAt to api/users/lookup (#19496)
* API: Add `createdAt` and `updatedAt` to api/users/lookup

In the past, we have added both `updatedAt` (#19004) and `createdAt` (#19475) to /api/users/:id

Turns out, api/users/lookup uses the same DTO for both. This fixes the serialization of both `createdAt` and `updatedAt`for this endpoint.

Also, adds a test to ensure no further regressions.

* Updated API documentation
2019-09-30 20:54:09 +01:00
Andrej Ocenas
3866814ea9
CLI: Fix version selection for plugin install (#19498) 2019-09-30 15:34:09 +02:00
Marcus Efraimsson
93919427f8
Upgrade grafana-plugin-model (#19438)
* use grafana-plugin-model dependency that uses go modules

* use grafana-plugin-model with updated hashicorp/go-plugin

* use grafana-plugin-model with re-compiled protos

* test using protoc-gen-go v1.2.0 tag

* use grafana-plugin-model with re-compiled protos

* chore: fix deprecation warning for lint

* use latest grafana-plugin-model

Fixes #19454
2019-09-30 15:16:04 +02:00
Rafael George
e1b2bf711d API: Add createdAt field to /api/users/:id (#19475)
It would help for auditing purposes to have the user's created date exposed via the API along with the other fields already exposed via the API.
2019-09-28 12:12:33 +01:00
Marcus Efraimsson
00e7c7c4b7
Testdata: Rename package to circumvent convention in go (#19409)
Before this change the tests for test datasource was not run.
2019-09-27 16:18:24 +02:00
Marcus Efraimsson
3de693af49
MySQL: Limit datasource error details returned from the backend (#19373)
Only return certain mysql errors from backend.
The following errors is returned as is from backend:
error code 1064 (parse error)
error code 1054 (bad column/field selected)
error code 1146 (table not exists)
Any other errors is logged and returned as a generic
error.
Restrict use of certain functions:
Do not allow usage of the following in query:
system_user()
session_user()
current_user() or current_user
user()
show grants

Fixes #19360
2019-09-24 20:50:49 +02:00
Erik Sundell
4dbedb8405 Azure Monitor: Revert support for cross resource queries (#19115)" (#19346)
This reverts commit 88051258e9.
2019-09-24 12:01:12 +02:00
Hugo Häggmark
75dcaecc99
Plugins: Skips existence of module.js for renderer plugins (#19318)
* Fix: Skips test for module.js for plugins of renderer type
Fixes #19130

* Refactor: Changes after PR comments

* Chore: Fixes go lint issue
2019-09-23 22:54:28 -07:00
gotjosh
279249ef56
Multi-LDAP: Do not fail-fast on invalid credentials (#19261)
* Multi-LDAP: Do not fail-fast on invalid credentials

When configuring LDAP authentication, it is very common to have multiple
servers configured. When using user bind (authenticating with LDAP using
the same credentials as the user authenticating to Grafana) we don't
expect all the users to be on all LDAP servers.

Because of this use-case, we should not fail-fast when authenticating on
multiple LDAP server configurations. Instead, we should continue to try
the credentials with the next LDAP server configured.

Fixes #19066
2019-09-23 13:34:05 +01:00
Marcus Efraimsson
19f3ec4891
MySQL, Postgres, MSSQL: Only debug log when in development (#19239)
Found some additional debug statements in relation to #19049 that 
can cause memory issues.

Ref #19049
2019-09-20 15:00:28 +02:00
Franco Papalardo
b8334c14f8 CloudWatch: ContainerInsights metrics support (#18971)
* CloudWatch ContainerInsights support
2019-09-20 12:05:58 +03:00
Andrew Rabert
8a991244d5 Alerting: Truncate PagerDuty summary when greater than 1024 characters (#18730)
Requests to PagerDuty fail with an HTTP 400 if the `summary` 
attribute contains more than 1024 characters, this fixes this.
API spec:
https://v2.developer.pagerduty.com/docs/send-an-event-events-api-v2

Fixes #18727
2019-09-20 10:39:27 +02:00
Brenda Harjala
c9e566b156 Docs: Minor edits to the README and several md files (#19238)
* Update README.md

Capitalized the G and S in "Getting Started," and moved "guide" to match the section title in the docs.

* Fixed sentence structure. Changed "download" to "grafana.com/get" and changed "get" to "download".

* Docs: Replace "datasources" with "data sources" (#19111)

* Docs: Replace "datasources" with "data sources" (#19111)

* Docs: Replace "datasources" with "data sources" (#19111)

* Docs: Replace "datasources" with "data sources" (#19111)

* Docs: Replace "datasources" with "data sources" (#19111)

* Docs: Replace "datasources" with "data sources" (#19111)

* Docs: Replace "datasources" with "data sources" (#19111)

* Docs: Replace "datasources" with "data sources" (#19111)

*  Docs: Replace "datasources" with "data sources" (#19111)

* Docs: Replace "datasources" with "data sources" (#19111)

* Docs: Replace "datasources" with "data sources" (#19111)

* Docs: Replace "datasources" with "data sources" (#19111)
2019-09-20 00:04:56 +02:00
gotjosh
b20a258b72
LDAP: Show non-matched groups returned from LDAP (#19208)
* LDAP: Show all LDAP groups

* Use the returned LDAP groups as the reference when debugging LDAP

We need to use the LDAP groups returned as the main reference for
assuming what we were able to match and what wasn't. Before, we were
using the configured groups in LDAP TOML configuration file.

* s/User name/Username

* Add a title to for the LDAP mapping results

* LDAP: UI Updates to debug view

* LDAP: Make it explicit when we weren't able to match teams
2019-09-19 16:13:38 +01:00
Sofia Papagiannaki
56f5106717
SQL: Rewrite statistics query (#19178)
* Rewrite statistics query
2019-09-19 14:15:26 +03:00
Kevin Printz
79f8433675 Cloudwatch: Fix autocomplete for Gamelift dimensions (#19145) (#19146) 2019-09-19 08:27:15 +02:00
Masudur Rahman
a41a7ea656 Backend: Remove redundant condition of ROLE_VIEWER (#19211) 2019-09-19 08:19:11 +02:00
Marcus Efraimsson
0f524fc947
MSSQL: Revert usage of new connectionstring format (#19203)
This reverts commit 2514209 from #18384. Reason is that it doesn't 
work due to xorm 0.7.1 which doesn't support this new connectionstring 
format.

Fixes #19189
Ref #18384
Ref #17665
2019-09-18 19:30:35 +02:00
Leonard Gram
dd794625dd
API: adds redirect helper to simplify http redirects (#19180) 2019-09-17 19:28:35 +02:00
Erik Sundell
88051258e9
Azure Monitor: Add support for cross resource queries (#19115)
* Add new query mode picker with different states for each query. Also really simple migration script

* Populate cross resource dropdowns

* Cleanup. Handle change events

* Add multi select picker for subscriptions

* Fix markup issue

* Prepare for new query mode

* More cleanup

* Handle multiple queries both in ds and backend

* Refactoring

* Improve migration

* Add support for multiselect display name

* Use multiselect also for locations and resources

* Add more typings

* Fix migrations

* Custom multiselect built for array of options instead of variables

* Add url builder test

* fix datasource tests

* UI fixes

* Improve query editor init

* Fix brokens tests

* Cleanup

* Fix tslint issue

* Change query mode display name

* Make sure alerting works for single queries

* Friendly error for multi resources

* Add temporary typings
2019-09-17 11:35:40 +02:00
Sofia Papagiannaki
b5f0a5d5ca
Api: Readonly datasources should not be created via the API (#19006)
* Readonly datasources should not be created via the API

* Return correct `ReadOnly` value in GetDataSourceByName
2019-09-17 12:29:43 +03:00
Alexander Zobnin
494b4aaf88 LDAP: only show tab if LDAP is enabled (#19156)
* LDAP: add nav link only if ldap enabled

* LDAP: /admin/ldap required admin permissions
2019-09-17 10:27:55 +02:00
Marcus Efraimsson
80592e3361
Metrics: Adds setting for turning off total stats metrics (#19142)
Don't update total stats metrics if reporting is disabled.
New setting disable_total_stats for turning off update 
of total stats (stat_totals_*) metrics.

Ref #19137
2019-09-17 09:32:24 +02:00
Peter Holmberg
3c61b563c3 Ldap: Add LDAP debug page (#18759)
* Add items for navmodel and basic page

* add reducer and actions

* adding user mapping table component

* adding components for ldap tables

* add alert box on error

* close error alert box

* LDAP status page: connect APIs WIP

* LDAP debug: fetch connection status from API

* LDAP debug: fetch user info from API

* LDAP debug: improve connection error view

* LDAP debug: connection error tweaks

* LDAP debug: fix role mapping view

* LDAP debug: role mapping view tweaks

* LDAP debug: add bulk-sync button stub

* LDAP debug: minor refactor

* LDAP debug: show user teams

* LDAP debug: user info refactor

* LDAP debug: initial user page

* LDAP debug: minor refactor, remove unused angular wrapper

* LDAP debug: add sessions to user page

* LDAP debug: tweak user page

* LDAP debug: tweak view for disabled user

* LDAP debug: get sync info from API

* LDAP debug: user sync info

* LDAP debug: sync user button

* LDAP debug: clear error on page load

* LDAP debug: add user last sync info

* LDAP debug: actions refactor

* LDAP debug: roles and teams style tweaks

* Pass showAttributeMapping to LdapUserTeams

* LDAP debug: hide bulk sync button

* LDAP debug: refactor sessions component

* LDAP debug: fix loading user sessions

* LDAP debug: hide sync user button

* LDAP debug: fix fetching unavailable /ldap-sync-status endpoint

* LDAP debug: revert accidentally added fix

* LDAP debug: show error when LDAP is not enabled

* LDAP debug: refactor, move ldap components into ldap/ folder

* LDAP debug: styles refactoring

* LDAP debug: ldap reducer tests

* LDAP debug: ldap user reducer tests

* LDAP debug: fix connection error placement

* Text update

* LdapUser: Minor UI changes moving things around

* AlertBox: Removed icon-on-top as everywhere else it is centered, want to have it be consistent
2019-09-16 18:56:01 +03:00
gotjosh
99c799e9b7
Close the connection only if we establish it. (#18897) 2019-09-16 14:13:35 +01:00
Dominik Prokop
97ff75732d
Routing: Update routing to require sign in on every route (#19118)
* Update routing to require sign in on every route

* Review update
2019-09-16 14:06:50 +02:00
Dominik Prokop
44a2a648c6
Login: fix login page failing when navigating from reset password views (#19124) 2019-09-16 13:38:03 +02:00
Marcus Efraimsson
2acffbeb10
CLI: Fix installing plugins on windows (#19061)
Fixes #19022
2019-09-13 18:12:52 +02:00
gotjosh
7b7b95341e
LDAP: Allow an user to be synchronised against LDAP (#18976)
* LDAP: Allow an user to be synchronised against LDAP
This PR introduces the /ldap/sync/:id endpoint. It allows a user to be synchronized against LDAP on demand.

A few things to note are:

LDAP needs to be enabled for the sync to work
It only works against users that originally authenticated against LDAP
If the user is the Grafana admin and it needs to be disabled - it will not sync the information
Includes a tiny refactor that favours the JSONEq assertion helper instead of manually parsing JSON strings.
2019-09-13 16:26:25 +01:00
Erik Sundell
4c8f417f18 Stackdriver: Add extra alignment period options (#18909)
* Add more alignment period options

* Remove unnecessary alignment period limit
2019-09-13 10:45:59 +02:00
548017
09b434bdd0 Auth: Allow inviting existing users when login form is disabled (#19048)
Allow api to accept inviting existing users when login form is disabled.
UI shows invite button when login form is disabled.
2019-09-12 18:45:50 +02:00
Brian Gann
9eafc693b2
MSSQL: Fix memory leak when debug enabled (#19049)
* fix for #19049
2019-09-12 18:44:31 +02:00
gotjosh
fa007423e3
API: Add updatedAt to api/users/:id (#19004)
* API: Add `updatedAt` to api/users/:id

This adds the timestamp of when a particular user was last updated to
the `api/users/:id` endpoint.

This helps our administrators understand when was the user information last
updated. Particularly when it comes from external systems e.g. LDAP
2019-09-11 13:43:05 +01:00
Kyle Brandt
e5bf3027fc
Refactor: Move sql_engine to sub package of tsdb (#18991)
this way importing the tsdb package does not come with xorm dependencies
2019-09-10 15:50:04 -04:00
Sofia Papagiannaki
7f40dc5317
Image rendering: Add deprecation warning when PhantomJS is used for rendering images (#18933)
* Add deprecation warning

* Update pkg/services/rendering/rendering.go

Co-Authored-By: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2019-09-10 16:16:51 +03:00
lzd
c9c0dd1ea8 Alerting: fix response popover prompt when add notification channels (#18967) 2019-09-09 14:09:21 +02:00
Sofia Papagiannaki
de075e529d
Build: Fix potential case-insensitive import collision for github.com/Unknwon/com (#18915)
* update gopkg.in/macaron.v1

* update github.com/go-macaron/binding

* update github.com/go-macaron/session

* Substitute github.com/Unknwon/com with github.com/unknwon/com

* Clean up modules using `go mod tidy`

* Substitute github.com/Unknwon/bra with github.com/unknwon/bra
2019-09-09 14:22:06 +03:00
Ryan McKinley
7d32caeac2 Transformers: configure result transformations after query(alpha) (#18740) 2019-09-09 08:58:57 +02:00
gotjosh
10fe101add
LDAP: Fetch teams in debug view (#18951)
Adds the definition of `GetTeamsForLDAPGroupCommand` which handles the lookup of team information based on LDAP groupDNs.

This is an Enterprise only feature. To diferentiate,a response will contain the `team` key as `null` on OSS while on Enterprise the key will contain an empty array `[]` when no teams are found.
2019-09-08 11:48:47 +01:00
Sofia Papagiannaki
388d3d3714
Notification is sent when state changes from no_data to ok (#18920) 2019-09-05 18:54:27 +03:00
gotjosh
7c6dd1868b
LDAP: Add API endpoint to query the LDAP server(s) status (#18868)
* LDAP: Add API endpoint to query the LDAP server(s) status|

This endpoint returns the current status(es) of the configured LDAP server(s).

The status of each server is verified by dialling and if no error is returned we assume the server is operational.

This is the last piece I'll produce as an API before moving into #18759 and see the view come to life.
2019-09-04 15:29:14 +01:00
gotjosh
0cbbb43222
LDAP: Add API endpoint to debug user mapping from LDAP (#18833)
* Move the ReloadLDAPCfg function to the debug file

Appears to be a better suite place for this.

* LDAP: Return the server information when we find a specific user

We allow you to specify multiple LDAP servers as part of LDAP authentication integration. As part of searching for specific users, we need to understand from which server they come from. Returning the server configuration as part of the search will help us do two things:

- Understand in which server we found the user
- Have access the groups specified as part of the server configuration

* LDAP: Adds the /api/admin/ldap/:username endpoint

This endpoint returns a user found within the configured LDAP server(s). Moreso, it provides the mapping information for the user to help administrators understand how the users would be created within Grafana based on the current configuration.

No changes are executed or saved to the database, this is all an in-memory representation of how the final result would look like.
2019-09-03 18:34:44 +01:00
Kyle Brandt
364d2358d8
alerting: add lock on job to prevent a race condition (#18218)
without this lock there is a race condition between the scheduler and job processing.
2019-09-03 09:14:28 -04:00
Marcus Efraimsson
964c2e722f
Snapshot: Fix http api (#18830)
(cherry picked from commit be2e2330f5)
2019-09-02 15:15:46 +02:00
Oleg Gaidarenko
1a4be4af8c
Enterprise: add dependencies for upcoming features (#18793)
* Enterprise: add dependencies for upcoming features

See enterprise issues
2019-08-30 18:14:32 +02:00
Gali Alykoff
f942fecc52 Chore: Improve err message for notifications (#18757)
Improve message of notification json error
Fix test after change error message
2019-08-28 16:49:36 +02:00
Marcus Efraimsson
e83f55f394 Chore: Use ruleId instead of alertId as log keyword (#18738) 2019-08-27 08:40:03 +02:00
Bob Shannon
056dbc7012 OAuth: Support JMES path lookup when retrieving user email (#14683)
Add support for fetching e-mail with JMES path

Signed-off-by: Bob Shannon <bobs@dropbox.com>
2019-08-26 18:11:40 +02:00
Oleg Gaidarenko
35b74a99a8
Emails: resurrect template notification (#18686)
* Emails: resurrect template notification

* Phantomjs (oh yeah, there is another dev dep phantom :-) was failing for
  the generation of the html templates so I had to update the dependencies
  in order to fix it. While doing that I update the scripts field and docs
  for it as well. yarn.lock is included

* Move splitting of the emails to separate helper function, since more services
  coming up that would need to use this functionality

* Add support for enterprise specific email letters. Probably could
  be done in the better way, but it's not a priority right now
2019-08-26 17:19:03 +02:00
Oleg Gaidarenko
c5bca40566
Email: add reply-to and direct attachment (#18715)
* Add support for `Reply-To` header

* Allow direct attachment

Don't have tests yet, but they will follow
2019-08-26 16:44:18 +02:00
Ryan McKinley
f7c55d3968 Plugins: better warning when plugins fail to load (#18671)
* better pluin feedback

* add server side check for module.js
2019-08-22 07:04:02 +02:00
Ryan McKinley
e6fbf358c8
TestData: attach labels to series results (#18653) 2019-08-21 07:50:13 -07:00
Oleg Gaidarenko
6ca1a6c8da
Auth: change the error HTTP status codes (#18584)
* Auth: change the error HTTP status codes

* Use 407 HTTP status code for incorrect credentials error

* Improve proxy auth logs

* Remove no longer needed TODO comment

Fixes #18439
2019-08-20 20:13:27 +03:00
Oleg Gaidarenko
02af966964
LDAP: multildap + ldap integration (#18588)
It seems `ldap` module introduced new error type of which
multildap module didn't know about.

This broke the multildap login logic

Fixes #18491
Ref #18587
2019-08-19 00:52:32 +03:00
kay delaney
fb0cec5591
Backend: Adds support for HTTP/2 (#18358)
* Backend: Adds support for HTTP/2

* Adds mozilla recommended ciphers

* Updates sample.ini and config documentation
2019-08-16 16:06:54 +01:00
Ryan McKinley
6335509a23 Annotations: use a single row to represent a region (#17673)
* SQLite migrations

* cleanup

* migrate end times

* switch to update with a query

* real migration

* anno migrations

* remove old docs

* set isRegion from time changes

* use <> for is not

* add comment and fix index decleration

* single validation place

* add test

* fix test

* add upgrading docs

* use AnnotationEvent

* fix import

* remove regionId from typescript
2019-08-16 10:49:30 +02:00
Kyle Brandt
f689b60426
remotecache: support SSL with redis (#18511)
* update go-redis lib from v2 -> v5
* add ssl option to the redis connection string
fixes #18498
2019-08-13 06:51:13 -04:00
Marcus Efraimsson
8fd153edb7
API: Restrict anonymous user information access (#18422)
Existing /api/alert-notifications now requires at least editor access.
Existing /api/alert-notifiers now requires at least editor access.
New /api/alert-notifications/lookup returns less information than
/api/alert-notifications and can be access by any authenticated user.
Existing /api/org/users now requires org admin role.
New /api/org/users/lookup returns less information than
/api/org/users and can be access by users that are org admins,
admin in any folder or admin of any team.
UserPicker component now uses /api/org/users/lookup instead
of /api/org/users.

Fixes #17318
2019-08-12 20:03:48 +02:00
Sofia Papagiannaki
4e29357d15
Backend: Do not set SameSite cookie attribute if cookie_samesite is none (#18462)
* Do not set SameSite login_error cookie attribute if cookie_samesite is none

* Do not set SameSite grafana_session cookie attribute if cookie_samesite is none

* Update middleware tests
2019-08-09 09:10:08 +03:00
Sofia Papagiannaki
7520166f17
API: Minor fix for team creation endpoint when using API key (#18252)
* Fix CreateTeam api endpoint

No team member should be created for requests
authenticated by API tokens.

* Update middleware test

Assert that `isAnonymous` is set for `SignedInUser`
authenticated via API key.

* Add test for team creation

Assert that no team member is created if the signed in user
is anomymous.

* Revert "Fix CreateTeam api endpoint"

This reverts commit 9fcc4e67f5.

* Revert "Update middleware test"

This reverts commit 75f767e58d.

* Fix CreateTeam api endpoint

No team member should be created for requests
authenticated by API tokens.

* Update team test

* Change error to warning and update tests
2019-08-08 11:27:47 +03:00
Alexander Zobnin
b47f0ff07f
OAuth: return GitLab groups as a part of user info (enable team sync) (#18388)
* GitLab OAuth: GetGroups refactor

* GitLab OAuth: fetch groups into UserInfo

* GitLab OAuth: minor refactor

* GitLab OAuth: team sync docs
2019-08-07 17:05:35 +03:00
Kyle Brandt
e1b2d61ceb
backend: null.Float NaN -> null for json marshal (#18284) 2019-08-06 12:28:48 -04:00
Sofia Papagiannaki
269c1fb107
Do not set SameSite for OAuth cookie if cookie_samesite is None (#18392) 2019-08-06 09:50:20 +03:00
Elykov Alexandr
2514209083 MSSQL: Change connectionstring to URL format to fix using passwords with semicolon (#18384)
Fixes #17665
2019-08-05 18:40:33 +02:00
Alexander Berger
4e1e220962 CloudWatch: Fix alerting for queries with Id (using GetMetricData) (#17899)
This commit addresses half of #13749 by making sure GetMetricData 
works for alerting. Math Expressions (compound metrics) will still not 
work for alerting, this would require a bigger refactoring of Grafana's 
alerting service. However, with this commit at least alerting for basic 
metrics with non empty query Id will work.

Fixes half of #13749
2019-08-05 17:28:09 +02:00
Oleg Gaidarenko
d88fdc86fc Auth: Do not search for the user twice (#18366)
* Auth: Do not search for the user twice

Previously `initContextWithBasicAuth` did not use `LoginUserQuery`, doing
`GetUserByLoginQuery` only i.e. looking user in DB only, things changed when
this function started to check LDAP provider via `LoginUserQuery` (#6940),
however, this request was placed after `GetUserByLoginQuery`, so we first
looking in DB then in the LDAP - if LDAP user hasn't logged in we will
not find it in DB, so `LoginUserQuery` will never be reached.

`LoginUserQuery` request already performs `GetUserByLoginQuery`
request in correct sequence. So we can just remove redundant request.

* Correct sequence execution during authentification &
  introduce tests for it

* Move basic auth tests to separate test file, since main test file already
  pretty large

* Introduce `testing.go` for the middleware module

* Remove redundant test helper function

* Make handler names more explicit

Ref 5777f65d05
Fixes #18329

* Auth: address review comment
2019-08-03 21:50:05 +02:00
Dominic Miglar
32d6740b8f Alerting: Also include configured AlertRuleTags in Webhooks (#18233)
* added alert rule tags in webhook notifications

* fix: don't include whole list of Tag objects but only key/value pairs in Webhook JSON

* marked webhook alerts to support alert rule tags
2019-08-03 17:00:40 +02:00
Oleg Gaidarenko
7e89a93b5f
Auth: introduce more tests for middleware module (#18365)
* Add tests for errors basic auth cases and moves tests to separate test-case.
Also names test cases consistently

* Add additional test helper

Ref 82661b9f69
2019-08-02 20:56:58 +03:00
Oleg Gaidarenko
fb273cb874
LDAP: nitpicks (#18309)
* LDAP: nitpicks

* Add more tests

* Correct and clarify comment for Login() method

* Rename methods (hail consistency!)

* Uppercases first letter of the logs everywhere

* Moves method definitions around to more appropriate places

Fixes #18295
2019-08-02 19:24:44 +03:00
Torkel Ödegaard
f3fb178efa Navigation: Fixed double settings menus (#18349) 2019-08-02 14:02:59 +02:00
Oleg Gaidarenko
82661b9f69 Auth: consistently return same basic auth errors (#18310)
* Auth: consistently return same basic auth errors

* Put repeated errors in consts and return only those consts as error strings

* Add tests for errors basic auth cases and moves tests to separate test-case.
  Also names test cases consistently

* Add more error logs and makes their messages consistent

* A bit of code style

* Add additional test helper

* Auth: do not expose even incorrect password

* Auth: address review comments

Use `Debug` for the cases when it's an user error
2019-08-02 11:16:31 +02:00
Leonard Gram
c675449aa2
cli: fix for recognizing when in dev mode. (#18334) 2019-08-02 09:38:41 +02:00
Sofia Papagiannaki
69b7b8bb46 Fix OAuth error due to SameSite cookie policy (#18332)
The `oauth_state` cookie used to be created with the SameSite value set
according to the `cookie_samesite` configuration.
However, due to a Safari bug SameSite=None or SameSite=invalid are treated
as Strict which results in "missing saved state" OAuth login failures
because the cookie is not sent with the redirect requests to the OAuth
provider.
This commit always creates the `oauth_state` cookie with SameSite=Lax
to compensate for this.
2019-08-01 15:47:04 +02:00
gotjosh
ed8aeb2999
Auth Proxy: Include additional headers as part of the cache key (#18298)
* Auth Proxy: Include additional headers as part of the cache key

Auth proxy has support to send additional user attributes as part of the
authentication flow. These attributes (e.g. Groups) need to be monitored
as part of the process in case of change.

This commit changes the way we compute the cache key to include all of the
attributes sent as part of the authentication request. That way, if we
change any user attributes we'll upsert the user information.
2019-07-31 11:23:00 +01:00
Andrej Ocenas
8c49d27705
CLI: Allow installing custom binary plugins (#17551)
Make sure all data is sent to API to be able to select correct archive version.
2019-07-29 10:44:58 +02:00
gotjosh
2f240a11ce SAML: Only show SAML login button on Enterprise version (#18270)
SAML Authentication is an Enterprise only feature. This change enables
the SAML login button to only be shown on enterprise.
2019-07-26 11:05:02 +02:00
Andrej Ocenas
7f1214ac46
Permissions: Show plugins in nav for non admin users but hide plugin configuration (#18234)
Allow non admins to see plugins list but only with readme. Any config tabs are hidden from the plugin page. Also plugin panel does not show action buttons (like Enable) for non admins.
2019-07-25 16:54:26 +02:00
Oleg Gaidarenko
1e5fc76601
LDAP: improve POSIX support (#18235)
* LDAP: improve POSIX support

* Correctly abtain DN attributes result

* Allow more flexibility with comparison mapping between POSIX group & user

* Add devenv for POSIX LDAP server

* Correct the docs

Fixes #18140
2019-07-24 12:49:18 +03:00
Dima Kurguzov
a4b0ccc138 Instrumentation: Add failed notifications metric (#18089) 2019-07-24 11:43:24 +02:00
Markus Blaschke
31547597d3 remote_cache: Fix redis connstr parsing (#18204)
* Fix redis connstr parsing

* Don’t log the password
2019-07-23 16:45:04 +03:00
Oleg Gaidarenko
d16fd58bdb
Auth: do not expose disabled user disabled status (#18229)
Fixes #17947
2019-07-23 13:12:55 +03:00
Kyle Brandt
ea0cee4c35
alerting: more specific error when missing threshold (#18221)
fixes #18184
2019-07-22 13:23:33 -04:00
Kyle Brandt
172464e91e
alerting: return err when SetAlertState fails to save to sql (#18216)
fix duplicate alert states when the alert fails to save to the database.
fixes #18176
2019-07-22 07:23:27 -04:00
Leonard Gram
2014549fa5 PhantomJS: Fixes rendering on Debian Buster (#18162)
Closes #17588
2019-07-20 13:03:10 +02:00
Raphael Couto
bc0da1bbfc Plugin: AzureMonitor - Reapply MetricNamespace support (#17282)
* Reapply MetricNamespace support

* Fixing tests

* refactor: move metricnamespace param to backend

* refactor: remove unused function

* azuremonitor: migration for new metric namespace field

* azuremonitor: add template query for metric namespace with a sub

* docs: template queries for azure monitor

Adds new lines for the metricnamespace template function and fixes
some messed up lines
2019-07-20 01:43:52 +02:00
Alexander Zobnin
ccf11fb7a2
SAML: add auth provider label (#18197) 2019-07-19 17:13:29 +03:00
Ryan McKinley
0ca1e90b2e
Plugins: fix previous commit, output "build" property in json 2019-07-19 06:21:39 -07:00
Alexander Zobnin
214195441f
SAML: add metrics (#18194) 2019-07-19 15:30:31 +03:00
Ryan McKinley
3e0625ff3d
Plugins: add build info to plugin metadata (#18164) 2019-07-18 11:52:34 -07:00
Kyle Brandt
7cac393ddc
datasource: testdata - add predicatable csv wave scenario (#18183) 2019-07-18 13:36:22 -04:00
Kyle Brandt
ed099d5ca0
datasource: testdata - add predictable pulse scenario (#18142)
Adds pulse waveform. Is predictable in the sense that the start of the waveform is aligned to epoch time (instead of the start of the query time). This makes a useful signal for manual testing of alerting in the devenv.
2019-07-17 15:48:08 -04:00
Oleg Gaidarenko
d9f01cb822
SQLStore: use bool pointer instead of string (#18111) 2019-07-17 06:24:56 +03:00
Oleg Gaidarenko
75fa1f0207 Metrics: use consistent naming for exported variables (#18134)
* Metrics: remove unused metrics

Metric `M_Grafana_Version` is not used anywhere, nor the mentioned
`M_Grafana_Build_Version`. Seems to be an artefact?

* Metrics: make the naming consistent

* Metrics: add comments to exported vars

* Metrics: use proper naming

Fixes #18110
2019-07-16 16:58:46 +02:00
Oleg Gaidarenko
8e0f091f14
SQLStore: allow to look for is_disabled flag (#18032)
* Add support for `is_disabled` to `CreateUser()`

* Add support for `is_disabled` to `SearchUsers()`
  Had to add it as a `string` type not as `bool`, since if that's property
  is omitted, we would have add it to SQL request, which might be dangerous

* Restructure desctructive tests and add more
2019-07-15 09:14:32 +03:00
Oleg Gaidarenko
09eb9a45ce
Metrics: add LDAP active sync summary metric (#18079) 2019-07-15 08:33:48 +03:00
Kyle Brandt
76d08989f0
provisioning: escape literal '$' with '$$' to avoid interpolation (#18045)
fixes #17986
2019-07-11 07:32:07 -04:00
Anthony Templeton
3680b95b44 Auth: Duplicate API Key Name Handle With Useful HTTP Code (#17905)
* API: Duplicate API Key Name Handle With Useful HTTP Code

* 17447: make changes requested during review

- use dialect.IsUniqueContraintViolation
- change if statement to match others
- return error properly

* Revert "17447: make changes requested during review"

This reverts commit a4a674ea83.

* API: useful http code on duplicate api key error w/ tests

* API: API Key Duplicate Handling

fixed small typo associated with error
2019-07-11 11:20:34 +03:00
Sofia Papagiannaki
f2ad3242be
API: Minor fix for nil pointer when trying to log error during creating new dashboard via the API (#18003)
* Minor fix for nil pointer when trying to log error

* Do not return error if a dashboard is created

Only log the failures

* Do not return error if the folder is created

Only log the failures
2019-07-11 09:45:29 +03:00
Marcus Efraimsson
6a3a2f5f94
CLI: Fix encrypt-datasource-passwords fails with sql error (#18014)
Now handles secure_json_data stored as null in database when
running the encrypt-datasource-passwords migration.

Fixes #17948
2019-07-10 12:28:40 +02:00
Leonard Gram
5d3a60d46e
LDAP: Adds bind before searching LDAP for non-login cases. (#18023) 2019-07-10 12:25:21 +02:00
Alexander Zobnin
5f0a7f43c3
Users: show badges for each auth provider (#17869)
* Users: show badges for each auth provider

* Chore: don't use functions in angular bindings

* Users: minor style changes to labels

* Chore: convert auth labels on the backed side, deduplicate frontend code

* Users: use authLabels everywhere instead of authModule

* User: fix edit user page style

* Users: minor fixes after review
2019-07-10 12:06:51 +03:00
Ryan McKinley
81ff856568
grafana-cli: allow installing plugins from a local zip file (#18021) 2019-07-10 00:40:33 -07:00
Leonard Gram
25506829be
LDAP: Adds back support for single bind. (#17999) 2019-07-09 14:12:17 +02:00
gotjosh
332920954e
SAML: Show SAML login button even if OAuth is disabled (#17993)
* Move the SAML button outside of the oauth div
* Don't attempt to search cookies with an empty name
2019-07-09 10:15:52 +01:00
Sofia Papagiannaki
78ca55f3d7
Fix: Break redirect loop if oauth_auto_login = true and OAuth login fails (#17974)
* Add tests for login view

* Fix OAuth auto login redirect loop

login_error cookie is only set when the OAuth login fails
for some reason. Therefore, the login view should return
immediately if a login_error cookie exists before trying
to login the user using OAuth again.

* Fix test

Use 'index-template' instead of 'index' for testing

* Add some comments
2019-07-09 09:37:24 +03:00
Marcus Efraimsson
962d4daabd
Api: Fix auth tokens returning wrong seenAt value (#17980)
Changes so a non-set seenAt property gets the createdAt value.

Fixes #17953
2019-07-08 14:30:02 +02:00
Oleg Gaidarenko
e2cf7c9698
LDAP: finishing touches (#17945)
* LDAP:Docs: `active_sync_enabled` setting

Mention `active_sync_enabled` setting and enable it by default

* LDAP: move "disableExternalUser" method

Idea behind new design of the LDAP module is to minimise conflation
between other parts of the system, so it would decoupled as much as
possible from stuff like database, HTTP transport and etc.

Following "Do One Thing and Do It Well" Unix philosophy principal, other things
could be better fitted on the consumer side of things.

Which what this commit trying to archive

* LDAP: correct user/admin binding

The second binding was not happening, so if the admin login/password
in LDAP configuration was correct, anyone could had login as anyone using
incorrect password
2019-07-05 17:49:00 +03:00
Leonard Gram
b67905a963
Auth: saml enabled check. (#17960) 2019-07-05 16:39:52 +02:00
Leonard Gram
e574147b1e Auth: SAML login button. (#17932)
* Auth: SAML login button.

* Fixed ts issue
2019-07-05 15:24:52 +02:00
gotjosh
e6b8a1529b
SAML: Configuration defaults, examples and dependencies (#17954)
* Add SAML configuration options

* Add crewjam/saml as a depdency

Needed as part of the enterprise SAML integration.

* Vendor github.com/stretchr/testify/require

The package require implements the same assertions as the `assert` package but stops test execution when a test fails.
2019-07-05 11:27:14 +01:00
Alexander Zobnin
48d5a1bcd3 OAuth: deny login for disabled users (#17957) 2019-07-05 11:35:04 +02:00
Daniel Lee
7e95ded164
AzureMonitor: remove duplicate query logic on the frontend (#17198)
* feat: AzureMonitor implements legend key on backend

To be able to remove the duplicated query logic on the
frontend, the backend code needs to implement alias
patterns for legend keys as well as allowing the default
list of allowed time grains to be overridden. Some metrics
do not support all the time grains and the auto timegrain
calculation can be incorrect if the list is not overridden.

* feat: AzureMonitor - removes duplicate query logic on frontend

* AzureMonitor small refactoring

Extracted method and tidied up the auto time grain
code.

* azuremonitor: support for auto time grains for alerting

Converts allowed timegrains into ms and saves in dashboard json.
This makes queries for alerting with an auto time grain work in
the same way as the frontend.

* chore: typings -> implicitAny count down to 3413

* azuremonitor: add more typings
2019-07-04 22:47:24 +02:00
Oleg Gaidarenko
444c4d5999
LDAP: Divide the requests (#17885)
* LDAP: Divide the requests

Active Directory does indeed have a limitation with 1000 results
per search (default of course).

However, that limitation can be workaround with the pagination search feature,
meaning `pagination` number is how many times LDAP compatible server will be
requested by the client with specified amount of users (like 1000). That feature
already embeded with LDAP compatible client (including our `go-ldap`).

But slapd server has by default stricter settings. First, limitation is not 1000
but 500, second, pagination workaround presumably (information about it a bit
scarce and I still not sure on some of the details from my own testing)
cannot be workaround with pagination feature.

See
https://www.openldap.org/doc/admin24/limits.html
https://serverfault.com/questions/328671/paging-using-ldapsearch
hashicorp/vault#4162 - not sure why they were hitting the limit in
the first place, since `go-ldap` doesn't have one by default.

But, given all that, for me `ldapsearch` command with same request
as with `go-ldap` still returns more then 500 results, it can even return
as much as 10500 items (probably more).

So either there is some differences with implementation of the LDAP search
between `go-ldap` module and `ldapsearch` or I am missing a step :/.

In the wild (see serverfault link), apparently, people still hitting that
limitation even with `ldapsearch`, so it still seems to be an issue.

But, nevertheless, I'm still confused by this incoherence.

To workaround it, I divide the request by no more then
500 items per search
2019-07-03 17:39:54 +03:00
Alexander Zobnin
3d848d0fdf
Teams: show proper label for each auth provider (#17860)
* Teams: show proper label for each auth provider

Teams: don't sore AuthModule in team_member table, use JOIN to get it instead

* Teams: fix AddTeamMember after last changes

* Teams: add more auth provider labels

* Teams: show external sync badge if LDAP is not enabled

* Teams: tests for getting auth module
2019-07-03 16:52:10 +03:00
Anthony Templeton
0d2be0a7ed Logging: Login and Logout logging actions (#17760) (#17883) 2019-07-03 15:16:00 +02:00
Sofia Papagiannaki
2ae6adef26
Codestyle: add guidelines for removing the m alias for models (#17890)
* Add guidelines for avoiding use of m alias for models

* Add suggestion for elimination of existing aliases
2019-07-03 11:36:01 +03:00
Oleg Gaidarenko
caa1314f44
Build: use golangci-lint as a make command (#17739)
* Build: use golangci-lint as a make command

* Since gometalinter was deprecated in favor of golangci-lint so it was
  replaced by it. Responsibilities held by the gometalinter was moved to
  golangci-lint

* There was some changes in implementation (that was also mentioned in
  the code comment) between the tools, which uncovered couple errors
  in the code. Those issues were either solved or disabled by
  the inline comments

* Introduce the golangci-lint config, to make their
  configuration more manageable

* Build: replace backend-lint.sh script with make
2019-07-02 16:06:59 +03:00
Leonard Gram
8f150c67aa
Docs upgrading deps (#17657)
* Docs: correct link to the Grafana build-container.

* Docs: documents usage on the gopath when upgrading deps.

* Dev docs: info for upgrading deps only in one location.
2019-07-02 09:43:25 +02:00
Leonard Gram
d71043609e
Testing: Include BatchRevoke for all tokens in the fake. (#17728) 2019-07-02 09:42:35 +02:00
Oleg Gaidarenko
ca136c7c22
Devenv:LDAP: couple simplifications for LDAP (#17807)
* Add LDAP config instead sed use

* Add container name

* Add SizeLimit option to client and to server.
  Probably useless at this point, but it's better to have it then otherwise
2019-07-01 15:09:04 +03:00
Oleg Gaidarenko
5836427794
Login: divide login errors by pkg and service (#17835)
Define errors in the login module only if they are used
2019-07-01 14:32:17 +03:00
Sofia Papagiannaki
f3f03ceb6a
Auth Proxy: Respect auto_sign_up setting (#17843)
* Add test for disabled auth proxy auto signup option

* Set correctly auth proxy auto signup
2019-07-01 14:29:41 +03:00
Alexander Zobnin
c2affdee1e
OAuth: return github teams as a part of user info (enable team sync) (#17797)
* OAuth: github team sync POC

* OAuth: minor refactor of github module

* OAuth: able to use team shorthands for github team sync

* support passing a list of groups via auth-proxy header
2019-07-01 12:30:17 +03:00
Marcus Efraimsson
0a3f977ea2
Usage Stats: Update known datasource plugins (#17787) 2019-06-26 21:15:45 +02:00
Sofia Papagiannaki
dc9ec7dc91
Auth: Allow expiration of API keys (#17678)
* Modify backend to allow expiration of API Keys

* Add middleware test for expired api keys

* Modify frontend to enable expiration of API Keys

* Fix frontend tests

* Fix migration and add index for `expires` field

* Add api key tests for database access

* Substitude time.Now() by a mock for test usage

* Front-end modifications

* Change input label to `Time to live`
* Change input behavior to comply with the other similar
* Add tooltip

* Modify AddApiKey api call response

Expiration should be *time.Time instead of string

* Present expiration date in the selected timezone

* Use kbn for transforming intervals to seconds

* Use `assert` library for tests

* Frontend fixes

Add checks for empty/undefined/null values

* Change expires column from datetime to integer

* Restrict api key duration input

It should be interval not number

* AddApiKey must complain if SecondsToLive is negative

* Declare ErrInvalidApiKeyExpiration

* Move configuration to auth section

* Update docs

* Eliminate alias for models in modified files

* Omit expiration from api response if empty

* Eliminate Goconvey from test file

* Fix test

Do not sleep, use mocked timeNow() instead

* Remove index for expires from api_key table

The index should be anyway on both org_id and expires fields.
However this commit eliminates completely the index for now
since not many rows are expected to be in this table.

* Use getTimeZone function

* Minor change in api key listing

The frontend should display a message instead of empty string
if the key does not expire.
2019-06-26 09:47:03 +03:00
Alexander Zobnin
dad894f1cc
API: get list of users with additional auth info (#17305)
* batch disable users

* batch revoke users tokens

* split batch disable user and revoke token

* API: get users with auth info and isExternal flag

* fix tests for batch disable users

* Users: refactor /api/users/search endpoint

* Users: use alias for "user" table

* Chore: add BatchDisableUsers() to the bus

* Users: order user list by id explicitly

* Users: return AuthModule from /api/users/:id endpoint

* Users: do not return unused fields

* Users: fix SearchUsers method after last changes

* User: return auth module as array for future purposes

* User: tests for SearchUsers()

* User: return only latest auth module in SearchUsers()

* User: fix JOIN, get only most recent auth module
2019-06-25 18:29:07 +03:00
Marcus Efraimsson
5713048f48
Alerting: Improve alert rule testing (#16286)
* tsdb: add support for setting debug flag of tsdb query

* alerting: adds debug flag in eval context

Debug flag is set when testing an alert rule and this debug
flag is used to return more debug information in test aler rule
response. This debug flag is also provided to tsdb queries so
datasources can optionally add support for returning additional
debug data

* alerting: improve test alert rule ui

Adds buttons for expand/collapse json and copy json to clipboard,
very similar to how the query inspector works.

* elasticsearch: implement support for tsdb query debug flag

* elasticsearch: embedding client response in struct

* alerting: return proper query model when testing rule
2019-06-25 08:52:17 +02:00
Marcus Efraimsson
eecd8d1064 Elasticsearch: Visualize logs in Explore (#17605)
* explore: try to use existing mode when switching datasource

* elasticsearch: initial explore logs support

* Elasticsearch: Adds ElasticsearchOptions type
Updates tests accordingly

* Elasticsearch: Adds typing to query method

* Elasticsearch: Makes maxConcurrentShardRequests optional

* Explore: Allows empty query for elasticsearch datasource

* Elasticsearch: Unifies ElasticsearchQuery interface definition
Removes check for context === 'explore'

* Elasticsearch: Removes context property from ElasticsearchQuery interface
Adds field property
Removes metricAggs property
Adds typing to metrics property

* Elasticsearch: Runs default 'empty' query when 'clear all' button is pressed

* Elasticsearch: Removes index property from ElasticsearchOptions interface

* Elasticsearch: Removes commented code from ElasticsearchQueryField.tsx

* Elasticsearch: Adds comment warning usage of for...in to elastic_response.ts

* Elasticsearch: adds tests related to log queries
2019-06-24 21:15:03 +01:00
gotjosh
2fb45eeec8
Grafana-CLI: Wrapper for grafana-cli within RPM/DEB packages and config/homepath are now global flags (#17695)
* Feature: Introduce a grafana-cli wrapper

When our users install the *nix packed version of grafana, tendency is to use the services and scripts installed as part of the package for grafana-server. These leverage the default configuration options by specifying the several default paths.

This introduces a similar approach for the grafana-cli binary. We exposed it through a wrapper to ensure a proper configuration is in place. To enable that, we add the .real suffix to the original binary (grafana-cli.real) and then use a bash script named grafana-cli as the wrapper.

* Make the config and homepath flags global

* Introduce `configOverrides` as a global flag

This flag allows us to pass configuration overrides as a string.

The string follows the convention of configuration arguments separated by a space e.g. "cfg:default.paths.data=/dev/nullX cfg:default.paths.logs=/dev/nullX"

Also, it is backwards compatible with similar the previous configuration method through tailing arguments. Tailing arguments take presedence over the configuration options string.

* Only log configuration information in debug mode

* Move the grafana-cli binary to $GRAFANA_HOME/bin

As part of the package install process, we copy all the release files and
directories into the grafana home directory. This includes the /bin folder
from where we copied the binaries into their respective destinations.
After that, the /bin folder gets deleted as we don't want to keep
duplicates of the binaries around.

As part of this commit, we moved the re-creation of /bin within
grafana-home and the copy of the original binary (again) after the
folder gets deleted.
2019-06-24 20:20:21 +01:00
Sofia Papagiannaki
e7e9d3619e
Add guidelines for SQL date comparisons (#17732) 2019-06-24 20:39:28 +03:00
Leonard Gram
4c97d26102 Docs: clarified usage of go get and go mod (#17637) 2019-06-24 18:29:57 +02:00
Kyle Brandt
0adbb001db RemoteCache: redis connection string parsing test (#17702) 2019-06-24 11:51:38 +02:00
Sofia Papagiannaki
d0852f0618
Fix link in pkg/README (#17714)
Remove leading backslash from url
2019-06-24 10:34:51 +03:00
Kyle Brandt
49f0f0e89e
config: fix connstr for remote_cache (#17675)
fixes #17643 and adds test to check for commented out lines (but will only catch `;`, not `#`).
2019-06-20 10:15:21 -04:00
Oleg Gaidarenko
1c08e58605
LDAP: small improvements to various LDAP parts (#17662)
* Add multildap config example

* Publicize mocks for multildap module
2019-06-19 15:46:04 +02:00
Kyle Brandt
bd08d8ce8e
middleware: fix Strict-Transport-Security header (#17644)
fixes #17641
2019-06-18 14:24:23 -04:00
gotjosh
7d68d6ede2
grafana-cli: Fix receiving flags via command line (#17617)
`grafana-cli` uses the third-party library to define the flags and not
the standard library. Using `flag.Parse` conflicts with the defined
flags from our third-party library.

In the case where `flag.Parse` is used, the CLI assumes that definitions
provided are not needed and will not define them; producing errors of
the kind `flag provided but not defined --example-flag`.

Using the context to read any arguments (including flags) is the
recommended approach by the third-party library.
2019-06-18 10:25:37 +01:00
Carl Bergquist
b98bb48d59
codestyle: styleguide and arch for grafanas backend (#17545) 2019-06-18 09:31:51 +02:00
Yann Verry
ed613194ac HTTPServer: Fix X-XSS-Protection header formatting (#17620)
Fixes #17619
2019-06-17 23:46:35 +02:00
gotjosh
6fbca90269
cli: grafana-cli should receive flags from the command line (#17606)
grafana-cli should allow configuration overrides to be received from the command line. e.g.

```
grafana-cli admin reset-password cfg:default.paths.logs=custom/log/directory/
```

Seems like we missed the inclusion of `flag.Parse` as we run the command,  to be able to consume them.

Additionally, it'll be useful for the user to know whenever these are being overriden or not - hence the addition of logging the configuration to be used as we run the command.
2019-06-17 11:27:26 +01:00
Oleg Gaidarenko
c853ef7318
SQLStore: extend user.SearchUsers method (#17514)
* SQLStore: extend `user.SearchUsers` method

Allow `user.SearchUsers` to search users based on their auth type
2019-06-14 09:50:38 +01:00
Leonard Gram
37e9988e95
ldap: makes mocks available for testing. (#17576)
* ldap: makes mocks available for testing.
2019-06-14 09:54:19 +02:00
Oleg Gaidarenko
1b1d951495 LDAP: refactoring (#17479)
* LDAP: use only one struct

* Use only models.ExternalUserInfo

* Add additional helper method :/

* Move all the helpers to one module

* LDAP: refactoring

* Rename some of the public methods and change their behaviour

* Remove outdated methods

* Simplify logic

* More tests
  There is no and never were tests for settings.go, added tests for helper
  methods (cover is now about 100% for them). Added tests for the main
  LDAP logic, but there is some stuff to add. Dial() is not tested and not
  decoupled. It might be a challenge to do it properly

* Restructure tests:
   * they wouldn't depend on external modules
   * more consistent naming
   * logical division

* More guards for erroneous paths

* Login: make login service an explicit dependency

* LDAP: remove no longer needed test helper fns

* LDAP: remove useless import

* LDAP: Use new interface in multildap module

* LDAP: corrections for the groups of multiple users

* In case there is several users their groups weren't detected correctly

* Simplify helpers module
2019-06-13 16:47:51 +02:00
Sofia Papagiannaki
7b70e7db2d
AuthProxy: Optimistic lock pattern for remote cache Set (#17485)
* Implementation of optimistic lock pattern

Try to insert the remote cache key and handle integrity error

* Remove transaction

Integrity error inside a transaction results in deadlock

* Remove check for existing remote cache key

Is no longer needed since integrity constrain violations are handled

* Add check for integrity constrain violation

Do not update the row if the insert statement fails
for other than an integrity constrain violation

* Handle failing inserts because of deadlocks

If the insert statement fails because of a deadlock
try to update the row

* Add utility function for returning SQL error code

Useful for debugging

* Add logging for failing expired cache key deletion

Do not shallow it completely

* Revert "Add utility function for returning SQL error code"

This reverts commit 8e0b82c79633e7d8bc350823cbbab2ac7a58c0a5.

* Better log for failing deletion of expired cache key

* Add some comments

* Remove check for existing cache key

Attempt to insert the key without checking if it's already there
and handle the error situations

* Do not propagate deadlocks created during update

Most probably somebody else is trying to insert/update
the key at the same time so it is safe enough to ignore it
2019-06-13 15:36:09 +02:00
Marcus Efraimsson
e1df51109e
Fix so that correct cache is provided to di registry (#17566)
This fix prevents Grafana from crashing after being logged in.

Ref #17519
2019-06-13 12:15:52 +02:00
Carl Bergquist
6809d2bb29
codestyle: moves cache to infra (#17519) 2019-06-13 10:55:38 +02:00
Maxim Ivanov
151fe240fc OAuth: Fix for wrong user token updated on OAuth refresh in DS proxy (#17541) 2019-06-12 13:47:38 +02:00
Kyle Brandt
599514ad68
middleware: add security related HTTP(S) response headers (#17522)
* x_xss_protection
  * strict_transport_security (HSTS)
  * x_content_type_options

these are currently defaulted to false (off) until the next minor release.

fixes #17509
2019-06-12 13:15:50 +02:00
Mario Trangoni
ab4e1526b3 Codestyle: Fix some goconst issues (#17530)
Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
2019-06-12 07:27:47 +02:00
Shavonn Brown
a20309d7d2
Feature: Parse user agent string in user auth token api response (#16… (#17504)
* Feature: Parse user agent string in user auth token api response (#16222)

* Adding UA Parser Go modules attempt (#16222)

* Bring user agent vals up per req

* fix tests

* doc update

* update to flatten, no maps

* update doc
2019-06-11 14:12:52 +02:00
Kyle Brandt
c09fe3c3b4
remote_cache: Fix redis (#17483)
* wip: fix remote cache for redis
connstr parsing and non-negative expires for #17377
TODO: finish parse, check zero case, find out why negative duration in the first place

* finish parse.
Still TODO, find out negative value, and decide if would be better to make database specific entries in the .ini file

* update ini files

* remove accidental uncomment in defaults.ini

* auth_proxy: expiration non-negative so expiration is not in the past

* fix test, revert neg in redis

* review: use errutil
2019-06-10 15:27:08 +02:00
Kyle Brandt
826d33ea37
auth_proxy: non-negative cache TTL (#17495)
fixes setex error with redis on #17377
2019-06-10 15:25:23 +02:00
Kyle Brandt
a95c7bfa6f
sqlstore: clean quota and user_auth_tokens when removing users (#17487)
fixes #17392
2019-06-10 13:35:47 +02:00
Oleg Kovalov
6a76a92aff Prometheus: Preallocate data for Prometheus backend response parsing (#17490) 2019-06-10 08:12:46 +02:00
Carl Bergquist
912df2e284
gtime: some code style refactoring (#17369) 2019-06-10 07:38:31 +02:00
Oleg Gaidarenko
2316414786
Add tests for multildap (#17358)
That should get us to 100% coverage
2019-06-07 15:16:00 +03:00
Carl Bergquist
1aadb4426a
metrics: expose stats about roles as metrics (#17469) 2019-06-06 16:39:35 +02:00
Thibault Chataigner
e06abb30aa Alerting: Add tags to alert rules (#10989)
Ref #6552
2019-06-06 13:29:30 +02:00
Jonathan Rockway
02975256d1 Tracing: allow propagation with Zipkin headers (#17009)
Closes #17006
2019-06-05 13:12:05 +02:00
Andrej Ocenas
1c3ad78672
Perf: Fix slow dashboards ACL query (#17427)
Fix slow ACL query for dashboards that was used as subquery on multiple places slowing down search and login in instances with many dashboards.
2019-06-05 10:55:50 +02:00
Utkarsh Bhatnagar
a9da7b5f1f Cloudwatch: Add AWS DocDB metrics (#17241)
Closes #16535
2019-06-05 08:49:48 +02:00
Augustin Husson
c8382ba435 Provisioning: Support folder that doesn't exist yet in dashboard provisioning (#17407)
closes #17320
2019-06-04 22:23:08 +02:00
Mario Trangoni
87760d4fde Codestyle: Fix govet issues (#17178)
ref #10381

Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
2019-06-04 22:00:05 +02:00
Marcus Efraimsson
b7a9533476
Database: Initialize xorm with an empty schema for postgres (#17357)
xorm introduced some changes in
https://github.com/go-xorm/xorm/pull/824 and
https://github.com/go-xorm/xorm/pull/876 which by default will use
public as the postgres schema and this was a breaking change compared
to before. Grafana has implemented a custom postgres dialect so above
changes wasn't a problem here. However, Grafana's custom database
migration was using xorm dialect to check if the migration table exists
or not.
For those using a custom search_path (schema) in postgres configured on
server, database or user level the migration table check would not find
the migration table since it was looking in public schema due to xorm
changes above. This had the consequence that Grafana's database
migration failed the second time since migration had already run
migrations in another schema.
This change will make xorm use an empty default schema for postgres and
by that mimic the functionality of how it was functioning before
xorm's changes above.
Fixes #16720

Co-Authored-By: Carl Bergquist <carl@grafana.com>
2019-06-03 16:45:03 +02:00
Hugo Häggmark
fb39831df2
Explore: Queries the datasource once per run query and uses DataStreamObserver (#17263)
* Refactor: Removes replaceUrl from actions

* Refactor: Moves saveState thunk to epic

* Refactor: Moves thunks to epics

* Wip: removes resulttype and queries once

* Refactor: LiveTailing uses observer in query

* Refactor: Creates epics folder for epics and move back actioncreators

* Tests: Adds tests for epics and reducer

* Fix: Checks for undefined as well

* Refactor: Cleans up previous live tailing implementation

* Chore: merge with master

* Fix: Fixes url issuses and prom graph in Panels

* Refactor: Removes supportsStreaming and adds sockets to DataSourcePluginMeta instead

* Refactor: Changes the way we create TimeSeries

* Refactor: Renames sockets to streaming

* Refactor: Changes the way Explore does incremental updates

* Refactor: Removes unused method

* Refactor: Adds back Loading indication
2019-06-03 14:54:32 +02:00
Carl Bergquist
d8736a2547
Alerting: golint fixes for alerting (#17246) 2019-06-03 10:25:58 +02:00
Alexander Zobnin
60ddad8fdb
Batch disable users (#17254)
* batch disable users

* batch revoke users tokens

* split batch disable user and revoke token

* fix tests for batch disable users

* Chore: add BatchDisableUsers() to the bus
2019-05-31 13:22:22 +03:00
Bernard Duggan
a0bb01103e MySQL/Postgres/MSSQL: Add parsing for day, weeks and year intervals in macros (#13086)
closes #11431
2019-05-30 09:58:29 +02:00
Oleg Gaidarenko
a3092dc57b
LDAP: remove unused function (#17351) 2019-05-29 16:12:42 +03:00
Oleg Gaidarenko
d4ef19737e
Enterprise: remove gofakeit dep (#17344)
* Enterprise: remove gofakeit dep

Since we decided to use our uuid generation inside util module

* Enterprise: result of execution of `go mod ...`
2019-05-29 15:55:51 +03:00
Abhilash Gnan
04d473b3e5 HTTP Server: Serve Grafana with a custom URL path prefix (#17048)
Adds a new [server] setting `serve_from_sub_path`. By enabling 
this setting and using a subpath in `root_url` setting, e.g.
`root_url = http://localhost:3000/grafana`, Grafana will be accessible 
on `http://localhost:3000/grafana`. By default it is set to `false` 
for compatibility reasons.

Closes #16623
2019-05-27 17:47:29 +02:00
Andrej Ocenas
151b24b95f CLI: Add command to migrate all datasources to use encrypted password fields (#17118)
closes: #17107
2019-05-27 10:47:21 +02:00
Marcus Efraimsson
b9181df212
Auth Proxy: Log any error in middleware (#17275)
Fixes so that errors happening in auth proxy middleware is logged.

Ref #17247
2019-05-27 10:38:17 +02:00
Oleg Gaidarenko
de92c360a1
LDAP: reduce API and allow its extension (#17209)
* Removes Add/Remove methods

* Publicise necessary fields and methods so we could extend it

* Publicise mock API

* More comments and additional simplifications

* Sync with master

Still having low coverage :/ - should be addressed in #17208
2019-05-27 10:36:49 +03:00
Marcus Efraimsson
5884e235fc
database: retry transaction if sqlite returns database is locked error (#17276)
Adds an additional sqlite error code 5 (SQLITE_BUSY) to the
transaction retry handler to add retries when sqlite
returns database is locked error.
More info: https://www.sqlite.org/rescode.html#busy

Ref #17247 #16638
2019-05-27 09:24:15 +02:00
Alexander Zobnin
a3a7916597
Auth: Logout disabled user (#17166)
* Feature: revoke user token when disabled

* Chore: fix linter error
2019-05-23 15:54:47 +03:00
Carl Bergquist
c87b2c9913
docs: fixes typo in provisioning docs (#17248)
closes #17196
2019-05-23 13:06:34 +02:00
Abhilash Gnan
ca6151e23f Alerting: Support for configuring content field for Discord alert notifier (#17017) 2019-05-23 08:31:02 +02:00
Oleg Gaidarenko
9b7f9dd9be
LDAP: consistently name the LDAP entities (#17203) 2019-05-22 15:30:03 +03:00
CodeLingo Bot
3ff3e0f2ac Defer closing of files (#17213)
Signed-off-by: CodeLingo Bot <bot@codelingo.io>
2019-05-22 08:48:47 +02:00
Alexander Zobnin
2d03815770
Users: Disable users removed from LDAP (#16820)
* Users: add is_disabled column

* Users: disable users removed from LDAP

* Auth: return ErrInvalidCredentials for failed LDAP auth

* User: return isDisabled flag in user search api

* User: mark disabled users at the server admin page

* Chore: refactor according to review

* Auth: prevent disabled user from login

* Auth: re-enable user when it found in ldap

* User: add api endpoint for disabling user

* User: use separate endpoints to disable/enable user

* User: disallow disabling external users

* User: able do disable users from admin UI

* Chore: refactor based on review

* Chore: use more clear error check when disabling user

* Fix login tests

* Tests for disabling user during the LDAP login

* Tests for disable user API

* Tests for login with disabled user

* Remove disable user UI stub

* Sync with latest LDAP refactoring
2019-05-21 14:52:49 +03:00
Ryan McKinley
1033f0f905 DataSourceMeta: add an option to get hidden queries (#17124)
* add an option to get hidden queries

* make sure you have meta

* supportsHiddenQueries

* remove spaces

* DataSources: hidden queries flag
2019-05-21 13:46:19 +02:00
Daniel Lee
fa9ffe38d2
Azuremonitor: multiple subscription support for alerting (#17195)
* fix: azuremonitor adds multi-sub support to alerting

* fix: AzureMonitor missing parameter in metadata func

getMetricMetadata function when called in the query ctrl
was missing a parameter for Subscription Id.

Also, made some tweaks to what happens when a chained
dropdown is changed to not reset all the fields that
are dependent on it.
2019-05-21 12:28:30 +02:00
Marcus Efraimsson
3b008d06b4
testdata: logs scenario (#17182)
Adds logs scenario which is quite basic and not that smart 
to begin with. This will hopefully ease development of 
Explore and support for logs in Grafana.
2019-05-21 09:21:59 +02:00
Marcus Efraimsson
c82df97bb2
testdata: scenarios returned are now sorted in a consistent way (#17181)
This makes sure the scenarios returned from API are sorted in a consistent
way and by that makes the values in scenario drop down always presented
ordered instead of jumping around.
2019-05-21 09:20:57 +02:00
Mario Trangoni
66ba2aa524 Fix gosimple issues (#17179)
Signed-off-by: Mario Trangoni <mjtrangoni@gmail.com>
2019-05-21 07:50:44 +02:00
Carl Bergquist
bfa7c3d963
alerting: golint fixes for alert notifiers. (#17167) 2019-05-20 15:23:06 +02:00
Oleg Gaidarenko
a0f5923b95
LDAP: add tests for initialBind (#17132)
* LDAP: add tests for initialBind

* LDAP: clarify comment for Login()
2019-05-20 15:57:52 +03:00
Carl Bergquist
bd5bcea5d0
alerting: fix a bunch of lint issues. (#17128) 2019-05-20 12:13:32 +02:00
Oleg Gaidarenko
35f227de11
Feature: LDAP refactoring (#16950)
* incapsulates multipleldap logic under one module

* abstracts users upsert and get logic

* changes some of the text error messages and import sort sequence

* heavily refactors the LDAP module – LDAP module now only deals with LDAP related behaviour

* integrates affected auth_proxy module and their tests

* refactoring of the auth_proxy logic
2019-05-17 14:57:26 +03:00
Oleg Gaidarenko
756da8a134
Fix: tighten revive exit code & make it happy (#17127)
* Revive should fail the build

* Fix the associated errors
2019-05-17 08:35:37 +03:00
Tom Petr
73e405978b add support for periodically reloading mysql client certs (#14892) 2019-05-16 13:45:22 +02:00
Andrej Ocenas
3dbc3251d1
Chore: Deduplicate sqlstore transaction code (#17069)
* Deduplicate transaction code

* More deduplication
2019-05-16 12:39:59 +02:00
Carl Bergquist
2904e2d9fe
Alertmanager: Replace illegal chars with underscore in label names (#17002)
closes #16624
2019-05-16 11:41:57 +02:00
Oleg Gaidarenko
be66ed9dab
Chore: explore possibilities of using makefile (#17039)
* Chore: explore possibilities of using makefile

This is an exploratory commit - I wanted to see how
revive/gosec linters could be integrated with makefile and our build scripts.

Looks better then I expected :)

* Chore: make revive happy

Revive execution was not supplied with path, if you restore there is couple
errors that were popping up - so I fixed them

* Chore: make revive happy
2019-05-16 00:29:26 +03:00
Carl Bergquist
c55e6016bf
backend: replace /pkg/errors with errutil (#17065) 2019-05-15 12:20:17 +02:00
Carl Bergquist
aed3d0d3ad
Remotecache: Avoid race condition in Set causing error on insert. (#17082)
* remotecache: avoid race condition in set

since set called the database twice without transactions another
operation could insert a value before the first operation completed.
which would raise an error on insert since the data have been inserted
by the other request.

closes #17079
2019-05-15 11:24:04 +02:00
Carl Bergquist
3df94c6f27
serverlock: run tests async should be more linear time wise (#17059) 2019-05-14 15:38:18 +02:00
Andrej Ocenas
fd10aa902d
Chore: Use executable dir instead of pwd in CLI for isDev check (#16974)
* Use executable dir for the dev check

* Handle executable in bin and platform dirs

* Remove commented code

* Rename variable
2019-05-14 14:13:41 +02:00
Oleg Gaidarenko
79ac3fd699
Chore: remove use of == false (#17036)
Interestingly enough, golint or revive doesn't not prohibit
the use that construction :)

Ref #17035
2019-05-14 10:18:28 +03:00
Carl Bergquist
13f137a17d
tech: avoid alias for importing models in alerting (#17041)
ref #14679
2019-05-14 08:15:05 +02:00
Oleg Gaidarenko
29ad72f048
Chore: reintroduce gosec (#17021)
It seems gosec memory issue was recently fixed.
We should be good to go again

Ref securego/gosec#307
2019-05-13 14:56:36 +03:00
zhulongcheng
2fff8f77dc move log package to /infra (#17023)
ref #14679

Signed-off-by: zhulongcheng <zhulongcheng.me@gmail.com>
2019-05-13 08:45:54 +02:00
Ryan McKinley
1d7bb2a763 DataSourceApi: convert interface to abstract class (#16979)
* DataSourceApi as class

* add diff signature

* Prometheus: moved directUrl to jsonData
2019-05-10 11:37:43 +02:00
zhulongcheng
34f6dda6e6 Notification: attempt to send notifications to all given email addresses (#16881)
Signed-off-by: zhulongcheng <zhulongcheng.me@gmail.com>
2019-05-10 08:39:51 +02:00
Ryan McKinley
56702902a1 Plugins: Remove dataFormats key and add skipDataQuery (#16984) 2019-05-10 07:46:14 +02:00
zhulongcheng
7ebbeb09cb Snapshot: use given key and deleteKey (#16876)
Signed-off-by: zhulongcheng <zhulongcheng.me@gmail.com>
2019-05-09 11:53:04 +02:00
Torkel Ödegaard
e1d408a66f
AddDataSource: Updated page design & categories (#16971)
* minor refactoring

* Added category

* Minor progress

* Progres

* Updated descriptions

* Added custom sort

* NewDataSource: progress

* Updated design

* NewDataSource: Updated design

* Updated link

* Feedback changes
2019-05-09 11:45:39 +02:00
Carl Bergquist
a86b8c8a04
http: remove dualstack since its deprecated (#16940)
Deprecated: Fast Fallback is enabled by default. To
disable, set FallbackDelay to a negative value.

https://golang.org/src/net/dial.go
2019-05-08 10:37:48 +02:00
Ryan McKinley
17ce1273ca AppPlugin: Menu Edit Url Fix (#16934) 2019-05-08 09:38:40 +02:00
Brian Gann
b07d0b1026 Plugins: Support templated urls in routes (#16599)
This adds support for using templated/dynamic urls in routes.
* refactor interpolateString into utils and add interpolation support for app plugin routes.
* cleanup and add error check for url parse failure
* add docs for interpolated route urls

Closes #16835
2019-05-07 18:55:39 +02:00
Carl Bergquist
f001815d9d
alerting: no notification when going from nodata -> pending (#16905)
ref #16496
2019-05-07 10:34:00 +02:00
Marcus Efraimsson
32a45077e7
Elasticsearch: Fix pre-v7.0 and alerting error (#16904)
This fixes a regression introduced in #16646 where using Elasticsearch 
pre-v7.0 and alerting resulted in an error when trying to deserialize the 
response of total number of hits.
Total number of hits is not in use by the backend so we're removing it 
for now to make ES 6 and 7 being able to deserialize search responses 
without errors.

Closes #15622
2019-05-06 15:12:18 +02:00
Marcus Efraimsson
1c1427520d
Security: Add new setting allow_embedding (#16853)
When allow_embedding is false (default) the Grafana backend 
will set the http header `X-Frame-Options: deny` in all responses 
to non-static content which will instruct browser to not allow 
Grafana to be embedded in `<frame>`, `<iframe>`, 
`<embed>` or `<object>`.

Closes #14189
2019-05-06 09:56:23 +02:00
Mark Goodwin
44e6da6b41 build: fix integer overflow in pkg/tsdb tests on 32bit platforms (#16818)
Several pkg/tsdb tests fail to compile on 32bit platforms due to
integer overflow.
2019-05-06 09:27:45 +02:00
Marcus Efraimsson
f778c1d971
Security: Responses from backend should not be cached (#16848)
Currently all API requests set Cache-control: no-cache to avoid browsers 
caching sensitive data. This fixes so that all responses returned from 
backend not are cached using http headers. The exception is the data proxy 
where we don't add these http headers in case datasource backend needs 
to control whether data can be cached or not.

Fixes #16845
2019-05-06 09:22:59 +02:00
Samuel
846b9327a5 LDAP: Added reload endpoint for LDAP config (#15470)
* 4843 - Added reload endpoint for LDAP config

closes #4843

* Refactor to make the reload work after master drifted
2019-05-03 14:53:07 +02:00
Ryan McKinley
013f1b8d19
App Plugins: support react pages and tabs (#16586) 2019-05-02 10:15:39 -07:00
Stephen SORRIAUX
3866839b19 Datasources: add support for POST HTTP verb for InfluxDB (#16690)
A new parameter `queryMode` is added to the InfluxDB datasource to provide a way to use POST instead of GET when querying the database. This prevents to get any error when querying the database with a heavy request.
Default configuration is kept to GET for backward compatibility. Tests and documentation have been added for this new behaviour.
2019-05-02 15:30:37 +02:00
Marcus Efraimsson
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
Oleg Gaidarenko
c1289b308f Chore: revise some of the gosec rules (#16713) 2019-05-01 11:36:02 +02:00
Carl Bergquist
9660356638
Auth: Enable retries and transaction for some db calls for auth tokens (#16785)
the WithSession wrapper handles retries and connection
management so the caller dont have to worry about it.
2019-04-30 14:42:01 +02:00
Andrej Ocenas
eb82a75668
Provisioning: Show file path of provisioning file in save/delete dialogs (#16706)
* Add file path to metadata and show it in dialogs

* Make path relative to config directory

* Fix tests

* Add test for the relative path

* Refactor to use path relative to provisioner path

* Change return types

* Rename attribute

* Small fixes from review
2019-04-30 13:32:18 +02:00
Andrej Ocenas
0433af6385
Config: Fixes bug where timeouts for alerting was not parsed correctly (#16784)
* Fix parsing of the config

* Remove unnecessary conversion

* Remove timeout modification

Co-Authored-By: aocenas <mr.ocenas@gmail.com>

* Remove unused import
2019-04-30 12:05:38 +02:00
Torkel Ödegaard
9b68952482 Provisioning: Trying to fix failing test (#16800)
* Provisioning: Trying to fix test

* Use better sync strategy for test

* Lower the timeout

* Remove commented code

Co-Authored-By: aocenas <mr.ocenas@gmail.com>
2019-04-30 10:35:54 +02:00
bergquist
f7c8d90d1a phantomjs: set web-security to true 2019-04-29 14:37:52 +02:00
Oleg Gaidarenko
66c9297c36
Feature: introduce LdapActiveSyncEnabled setting (#16787)
* Feature: introduce LdapActiveSyncEnabled setting

We probably remove it after the active sync is done.
But at the moment we do not want to affect the current users
with not fully tested feature

* Chore: move settings in more logical order
2019-04-27 09:03:59 +03:00
Oleg Gaidarenko
62b85a886e
LDAP Refactoring to support syncronizing more than one user at a time. (#16705)
* Feature: add cron setting for the ldap settings

* Move ldap configuration read to special function

* Introduce cron setting (no docs for it yet, pending approval)

* Chore: duplicate ldap module as a service

* Feature: implement active sync

This is very early preliminary implementation of active sync.
There is only one thing that's going right for this code - it works.

Aside from that, there is no tests, error handling, docs, transactions,
it's very much duplicative and etc.

But this is the overall direction with architecture I'm going for

* Chore: introduce login service

* Chore: gradually switch to ldap service

* Chore: use new approach for auth_proxy

* Chore: use new approach along with refactoring

* Chore: use new ldap interface for auth_proxy

* Chore: improve auth_proxy and subsequently ldap

* Chore: more of the refactoring bits

* Chore: address comments from code review

* Chore: more refactoring stuff

* Chore: make linter happy

* Chore: add cron dep for grafana enterprise

* Chore: initialize config package var

* Chore: disable gosec for now

* Chore: update dependencies

* Chore: remove unused module

* Chore: address review comments

* Chore: make linter happy
2019-04-26 15:47:16 +03:00
Ryan McKinley
470634e2d6
Streaming: support streaming and a javascript test datasource (#16729) 2019-04-25 14:01:02 -04:00
Oleg Gaidarenko
78cd9058a3
Feature: add cron setting for the ldap settings (#16673)
* Feature: add cron setting for the ldap settings

* Move ldap configuration read to special function

* Introduce cron setting (no docs for it yet, pending approval)

* Chore: address code review comments
2019-04-25 17:12:56 +03:00
Alcides Viamontes E
cff2be0d66 elasticsearch: add 7.x version support (#16646)
Adds a new version option 7.0+ (70 internally).
Version 7.0+ doesn't include document types in index mappings 
so support for handling this have been added.
Version 7.0+ returns number of hits in a different way so 
support for handling this have been added.
Version 7.0+ doesn't support sending 
max_concurrent_shard_requests in multisearch header so 
support for sending this in query string have been added.
Update elastic6 docker block and dashboards (devenv) to use 
6.7.1 images, filebeat index name is now filebeat-YYYY.MM.DD 
and dashboard include correct tags and links.
Add elastic7 docker block and provisioning (devenv).
Updates documentation regarding new version.

Closes #15622
2019-04-25 09:41:13 +02:00
Andrej Ocenas
42b745a098
Provisioning: Add API endpoint to reload provisioning configs (#16579)
* Add api to reaload provisioning

* Refactor and simplify the polling code

* Add test for the provisioning service

* Fix provider initialization and move some code to file reader

* Simplify the code and move initialization

* Remove unused code

* Update comment

* Add comment

* Change error messages

* Add DashboardProvisionerFactory type

* Update imports

* Use new assert lib

* Use mutext for synchronizing the reloading

* Fix typo

Co-Authored-By: aocenas <mr.ocenas@gmail.com>

* Add docs about the new api
2019-04-25 09:06:44 +02:00
Hofls
b3bfbc6f77 Config: Show user-friendly error message instead of stack trace (#16564)
Fixes #16283
2019-04-25 08:29:07 +02:00
Tom Petr
2d6b33ab61 sqlstore: use column name in order by (#16583)
Use column name in ORDER BY in GetDashboardAclInfoList().
2019-04-24 16:05:35 +02:00
Andrej Ocenas
fcebd713a5
Provisioning: Interpolate env vars in provisioning files (#16499)
* Add value types with custom unmarshalling logic

* Add env support for notifications config

* Use env vars in json data tests for values

* Add some more complexities to value tests

* Update comment with example usage

* Set env directly in the tests, removing patching

* Update documentation

* Add env var to the file reader tests

* Add raw value

* Post merge fixes

* Add comment
2019-04-24 15:39:47 +02:00
Carl Bergquist
eb8af01a8a
admin: add more stats about roles (#16667)
closes #14967
2019-04-24 13:18:16 +02:00
Marcus Efraimsson
7dadebb3f0
playlist: fix loading dashboards by tag (#16727)
Fixes #16704
2019-04-24 10:10:16 +02:00
Utkarsh Bhatnagar
89a01a680c CloudWatch: Use default alias if there is no alias for metrics (#16732)
Fixes #16605
2019-04-24 10:00:02 +02:00
Josh
fca5ee4bea Provisioning: Support FolderUid in Dashboard Provisioning Config (#16559)
* add folderUid to DashbaordsAsConfig structs and DashbardProviderConfigs struct, set these values in mapping func
look for new folderUid values in config_reader tests
set dashboard folder Uid explicitly in file_reader, which has no affect when not given

* formatting and docstrings

* add folderUid to DashbaordsAsConfig structs and DashbardProviderConfigs struct, set these values in mapping func
look for new folderUid values in config_reader tests
set dashboard folder Uid explicitly in file_reader, which has no affect when not given

* formatting and docstrings

* add folderUid option, as well as documentation for the rest of the fields

* add blank folderUid in devenv example.

* add folderUid to provisioning sample yaml

* instead of just warning, return error if unmarshalling dashboard provisioning file fails

* Removing the error handling and adding comment

* Add duplicity check for folder Uids


Co-authored-by: swtch1 <joshua.thornton@protonmail.com>
2019-04-24 08:57:42 +02:00
Andrej Ocenas
e4f649e2c8
Chore: Small improvements to grafana-cli (#16670)
* Small improvements

* Better error handling
2019-04-23 12:34:34 +02:00
Andrej Ocenas
c429934a66
Chore: Use x/xerrors instead of pkg/errors (#16668)
* Use xerrors instead of pkg/errors

* Add Wrap util func

* Move Wrap to errutil package
2019-04-23 11:50:31 +02:00
Oleg Gaidarenko
54c1bf0cc9
Chore: a bit of spring cleaning (#16710)
* Chore: use early return technic everywhere

And enable "indent-error-flow" revive rule

* Chore: remove if-return rule from revive config

* Chore: improve error messages

And enable "error-strings" revive rule

* Chore: enable "error-naming" revive rule

* Chore: make linter happy

* Chore: do not duplicate gofmt execution

* Chore: make linter happy

* Chore: address the pull review comments
2019-04-23 11:24:47 +03:00
Oleg Gaidarenko
db584b3d28
Chore: remove session storage references (#16445)
* Chore: remove session storage references

* Small refactoring of the settings module

* Update docs - remove references for the session storage

* Update config files (sample and default configs)

* Add tests for warning during the config load on defined storage cache

* Remove all references to session storage

* Remove macaron session dependency

* Remove leftovers

* Fix: address review comments

* Fix: remove old deps

* Fix: add skipStaticRootValidation = true to tests

* Fix: improve the docs and warning message

As per discussion in here - https://github.com/grafana/grafana/pull/16445/files#r273026255

* Chore: make linter happy

Fixes #16148
Ref #16114
2019-04-22 18:58:24 +03:00
Torkel Ödegaard
36d64fecea
Search: Fixed search issue introduced in recent PR (#16652) 2019-04-17 19:07:13 +02:00
Carl Bergquist
e4eb0817e4 Cloudwatch: fix for flaky tests (#16649)
The iteration order over maps is not specified and is not guaranteed
to be the same from one iteration to the next. If a map entry that
has not yet been reached is removed during iteration, the corresponding
iteration value will not be produced. If a map entry is created during
iteration, that entry may be produced during the iteration or may be skipped.
The choice may vary for each entry created and from one iteration to
the next. If the map is nil, the number of iterations is 0.

https://golang.org/ref/spec#For_range
2019-04-17 19:06:32 +02:00
Torkel Ödegaard
8b0dd4244b
Search: Fixes search limits and adds a page parameter (#16458)
* Search: Fixes search limits and adds a page parameter

This adds a page parameter to search api without adding
any major breaking change.

It does at an api validation error when trying to use
a limit beyond 5000. This is a breaking change. We could
remove this and have it only in the docs and describe that this
is a limit that grafana will apply silently.

Fixes #16049

* Fix: Corrected wrong array slice change

* Docs: minor docs fix

* Search: fixed folder tests

* Fixed: Moved limit to correct inner query

* Search: moving limit check and page check

* Search: limit in handler is no longer needed
2019-04-17 13:07:50 +02:00
Carl Bergquist
3f136e0da9
tech: replace bmizerany/assert with stretchr/testify (#16625)
bmizerany is old and unsupported. so we are replacing it
with stretchr which is an drop in replacement and something
we want to use more in Grafana.
2019-04-17 10:25:58 +02:00
Torkel Ödegaard
75f9adf44f
Build: adding dependency used by extensions (#16622) 2019-04-16 15:26:39 +02:00
Oleg Gaidarenko
318182ccc9 Chore: refactor auth proxy (#16504)
* Chore: refactor auth proxy

Introduced the helper struct for auth_proxy middleware.
Added couple unit-tests, but it seems "integration" tests already cover
most of the code paths.

Although it might be good idea to test every bit of it, hm.
Haven't refactored the extraction of the header logic that much

Fixes #16147

* Fix: make linters happy
2019-04-16 14:09:18 +02:00
Carl Bergquist
68f5ddf18c
replace dep with go modules (#16017)
- guide shamelessly stolen from prometheus/prometheus
- updates local interface of oauth exchange
- updates local impl of hclogger
- bump jaeger client version

closes #16088
2019-04-16 12:00:55 +02:00
Carl Bergquist
490515aec6
build: partially replace gometalinter with golangci-lint (#16610)
we still use gometalinter for goconst since it doesn't 
report errors for duplicated in test files
2019-04-16 10:27:07 +02:00
Mitsuhiro Tanda
864a6262fe CloudWatch: GetMetricData refactoring & fix label handling (#16383)
* fix label handling

* SEARCH() results could have multiple namespace, remove from legend

* divide GetMetricStatistics related code

* divide GetMetricData related code

* divide parseGetMetricDataResponse()

* divide parseGetMetricDataQuery()

* divide test code

* add test for GetMetricData

* add test for GetMetricData parse response

* fix bug of terminating gap

* fix gofmt
2019-04-15 17:55:07 +02:00
Oleg Gaidarenko
b37ee65bd3
Chore: prepare our SQL for cockroach db (#16471)
This is basically implementation of the https://github.com/grafana/grafana/issues/8900#issuecomment-435437167
points, except for the type conversion bit.

I tried to implement idea mentioned in cockroachdb ticket (see below).
And it is possible, but it complicates things as lot - not only we have to
have 4 SQL statements instead of one, but we would have to copy the column
structure as well - PK, FG, indexes and stuff, plus there will
be additional downtime with this approach.

So idea for this pull is to prepare our SQL as much as possible, so when
cockroachdb will add support for full type conversions, we could easilly add
support for it as well.

* Add `CASCADE` to `DROP INDEX` statement

* Make string conversions explicit

Thanks @Luit

Ref #8900
Ref cockroach/cockroach#9851
2019-04-15 18:49:24 +03:00
Andrej Ocenas
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
Carl Bergquist
9134251417
build: upgrades to golang 1.12.4 (#16545)
fix govet issue in golang 1.12.4
2019-04-15 09:18:28 +02:00
Hofls
c17226af95 Pushover alert, support for different sound for OK (#16525)
Closes #15889
2019-04-12 14:57:17 +02:00
Ryan McKinley
3c21a121eb Plugins: Unifying alpha state & options for all plugins (#16530)
* app pages

* app pages

* workign example

* started alpha support

* remove app stuff

* show warning on alpha/beta panels

* put app back on plugin file

* fix go

* add enum for PluginType and PluginIncludeType

* Refactoring and moving settings to plugins section

fixes #16529
2019-04-12 13:46:42 +02:00
Carl Bergquist
30dcf0f6c5
Revert "Build: Upgrades to go 1.12.3 (#16491)" (#16544)
This reverts commit 44b365028f.
2019-04-12 11:17:31 +02:00
Carl Bergquist
44b365028f
Build: Upgrades to go 1.12.3 (#16491)
fixes go vet issue that 1.12.3 detects
2019-04-12 09:44:02 +02:00
Dan Cech
b9cc476eb7 Update jwt regexp to include = (#16521)
Fixes #16501
2019-04-11 15:30:55 +02:00
Ryan McKinley
d6887bf77f Plugins: Optionally preload some plugins during frontend app boot (#15266)
* auto load

* update comments

* gofmt

* use preload from json

* fix formatting

* change general plugin loader to app

* Refactoring: Plugin preloading #15266
2019-04-11 08:02:22 +02:00
Andrej Ocenas
2d7fc55df7
Provisioning: Do not allow deletion of provisioned dashboards (#16211)
* Unprovision dashboard in case of DisableDeletion = true

* Rename command struct

* Handle removed provision files

* Allow html in confirm-modal

* Do not show confirm button without onConfirm

* Show dialog on deleting provisioned dashboard

* Changed DeleteDashboard to DeleteProvisionedDashboard

* Remove unreachable return

* Add provisioned checks to API

* Remove filter func

* Fix and add tests for deleting dashboards

* Change delete confirm text

* Added and used pkg/errors for error wrapping
2019-04-10 13:29:10 +02:00
Oleg Gaidarenko
67cbc7d4cf
Chore: use remote cache instead of session storage (#16114)
Replaces session storage in auth_proxy middleware with remote cache

Fixes #15161
2019-04-08 14:31:46 +03:00
Marcus Efraimsson
5da1faf454
Alerting: Notification channel http api fixes (#16379)
Fixes so it's possible to create new notification channel and providing uid.
Fixes better error/result handling when updating a notifcation channel.

Fixes #16372
Ref #16219 #16012
2019-04-04 17:52:40 +02:00
Andrej Ocenas
08ce7f6c93
Chore: Add task to find FocusConvey tests (#16381) 2019-04-04 14:48:11 +02:00
The Rock Guy
335aa7c9f2 CloudWatch: Update AWS/IoT metric and dimensions (#16337)
Closes #16334
2019-04-04 12:54:20 +02:00
Marcus Efraimsson
79b86466fd Fix: Alerting Notification channel http api fixes (#16288)
Fix so that uid can be changed when updating notification
channels through the http api.
Update documentation
2019-03-29 09:42:38 +01:00
Zzy
1b84a924a3 Alerting: Makes timeouts and retries configurable (#16259)
Adds new alert settings for configuring timeouts and retries named 
evaluation_timeout_seconds, notification_timeout_seconds 
and max_attempts.

Closes #16240
2019-03-29 12:58:37 +07:00
Oleg Gaidarenko
1d955a8762
Chore: Implement gosec (#16261)
See https://github.com/securego/gosec for more info.

Disabled a lot of rules. I guess we should go through them
and recheck if we really need to disable some

Fixes #16204
2019-03-28 14:17:07 +01:00
Oleg Gaidarenko
04b3afcd15
Chore: Implement revive (#16200)
Since we do not like some of the default golint rules,
this commit proposes to use https://github.com/mgechev/revive.

And potential revive speed-up should't hurt :).

Right now, presented config (./conf/revive.toml) is permissive,
we might improve it over time however. Fixes for found revive
issues in the code are very limited so it wouldn't be large to review.

Also in this commit:

* Add annotations for makefile commands and declare phony targets

* Rename "gometalinter" script and CI command to "lint"
  since we are doing there a bit more then using gometalinter package

* Add Makefile rules to .editorconfig

* Documentation which mentioned "golint" replaced with revive

Fixes #16109
Ref #16160
2019-03-27 17:53:49 +01:00
Floyd May
33d1d427bc InfluxDB: Fix tag names with periods in alerting (#16255)
Updates regex to match tag names with periods when generating
series names in alerting evaluation (backend).

Fixes #9148
2019-03-27 23:13:12 +07:00
Navaneesh Kumar
5ea823a65a Fix: Alert email variable name typo fixed (#16232) 2019-03-27 09:42:20 +01:00
Marcus Efraimsson
2ae63e70c0
Alerting: Notification channel http api enhancements (#16219)
Now returns uid in response to get notification channel by id.
Adds GET/PUT/DELETE support for notification channel by uid, 
  /api/alert-notifications/uid/:uid.
Break apart alerting and alert notification http api docs in two 
  pages and update documentation to make it up to date
  with current implementation.

Fixes #16012
2019-03-26 18:37:02 +07:00
Marcus Efraimsson
6b8e3122f8
chore(influx): no point of reading response when bad status (#16212)
There's no point in reading the body response without using
the result so removing it.

Fixes #9199
Ref #16207
2019-03-26 12:10:24 +07:00
Daniel Lee
fda7e686f3
Merge pull request #15205 from seanlaff/12556-oauth-pass-thru
Add oauth pass-thru option for datasources
2019-03-25 21:52:20 +01:00
Ramon Carvalho Maciel
d791a6211d fix(InfluxDB): Reads body and close request body even for error status codes (#16207) 2019-03-25 17:42:26 +01:00
Torkel Ödegaard
7c81f4dfd8
fix(Alerting): Fixed alert rules with eval in day units, fixes #16174 (#16182) 2019-03-25 16:27:58 +01:00
Daniel Lee
c7d108264d
Merge pull request #16137 from mtanda/cloudwatch_update_metrics_list
update cloudwatch metrics/dimensions list
2019-03-25 14:42:15 +01:00
Torkel Ödegaard
46a75099d8
Merge pull request #16116 from SGI495/master
Don't include non-existing image in MS Teams alert
2019-03-22 09:34:56 +01:00
Mitsuhiro Tanda
4d8eb76dca update cloudwatch metrics/dimensions list 2019-03-22 00:08:17 +09:00
Sean Lafferty
50c5854430 Use grafana's logger implementation 2019-03-21 08:13:03 -04:00
Mitsuhiro Tanda
56251ca546 Update CloudWatch metrics/dimension list (#16102)
update cloudWatch metrics/dimension list
2019-03-21 11:13:06 +01:00
Sean Lafferty
b3461c9806 Remove sleeps in test code by overriding time.Now() 2019-03-20 15:34:31 -04:00
Sean Lafferty
3b9b6c571a Abstract encrypt/encode and decode/decrypt into their own functions 2019-03-20 15:18:22 -04:00
Sean Lafferty
b696492891 Rename dispatched commands to make them easy to grok 2019-03-20 14:32:41 -04:00
Sean Lafferty
be6e76ee35 Use structured logging instead of printf 2019-03-20 14:25:26 -04:00
Magnus Berglund
e6623de6b2 Rewrote creation of images tag 2019-03-20 18:59:13 +01:00
Magnus Berglund
0511095303 Added missing commas 2019-03-20 18:42:48 +01:00
Magnus Berglund
0de77598d7 Don't include non-existing image in MS Teams alert
If an image section is included in the JSON payload for MS Teams alerts
when no image URL exists, rendering of the alert in the client fails.
This change makes sure that an image section is only included in the
JSON payload if an image URL exists.

Closes #16082
2019-03-20 18:23:36 +01:00
Oleg Gaidarenko
30f0c35006
Merge pull request #16104 from markelog/remotecache-small-fix
Correct table names of sql storage for remotecache
2019-03-20 14:08:02 +01:00
Oleg Gaidarenko
c5bc723a6e Correct table names of sql storage for remotecache 2019-03-20 13:24:56 +01:00
Torkel Ödegaard
d11695b8b5 Fixed gofmt issue in PR #16093 2019-03-20 10:58:20 +01:00
Sai Ram Gupta
6929593eb6
Update org_user.go
Add check for, if current role is ROLE_VIEWER, return true if the role I'm checking for is ROLE_VIEWER. Fixes #16092
2019-03-19 11:31:55 -07:00
Leonard Gram
978c20a604 teams: explains the external property of a team membership. 2019-03-19 14:01:22 +01:00
Hugo Häggmark
53c74fa2f5 teams: refactor so that you can only delete teams if you are team admin 2019-03-19 14:01:21 +01:00
Leonard Gram
a615b78f8a permissions: removes global access to bus from MakeUserAdmin. 2019-03-19 14:01:20 +01:00
Leonard Gram
adf0390b2c teams: local access to bus, moving away from dep on global. 2019-03-19 14:01:20 +01:00
Leonard Gram
6589a4e55f teams: better names for api permissions. 2019-03-19 14:01:20 +01:00
Leonard Gram
9f33f00343 teams: refactor. 2019-03-19 14:01:19 +01:00
Leonard Gram
9f8e43916d permissions: refactor. 2019-03-19 14:01:19 +01:00
Leonard Gram
b796027bc6 teams: refactor. 2019-03-19 14:01:19 +01:00
Leonard Gram
d1481cac50 teams: refactored db code. 2019-03-19 14:01:18 +01:00
Hugo Häggmark
6a63725df0 teams: comment explaining input validation
Co-Authored-By: xlson <leo@xlson.com>
2019-03-19 14:01:17 +01:00
Leonard Gram
3f57a81c47 teams: cleanup. 2019-03-19 14:01:16 +01:00
Leonard Gram
ccfd6789ca teams: cleanup. 2019-03-19 14:01:16 +01:00
Leonard Gram
fc0461134f dashboards: simplified code. 2019-03-19 14:01:15 +01:00
Hugo Häggmark
b60e71c28b teams: moved logic for searchteams to backend 2019-03-19 14:01:15 +01:00
Hugo Häggmark
782b5b6a3a teams: viewers and editors can view teams 2019-03-19 14:01:14 +01:00
Leonard Gram
c420af16b1 teams: editor/viewer team admin cant remove the last admin. 2019-03-19 14:01:14 +01:00
Hugo Häggmark
246e128048 teams: changed permission to permission type instead of int 2019-03-19 14:01:14 +01:00
Hugo Häggmark
c826f39a8b teams: defaulting invalid permission level to member permission level 2019-03-19 14:01:13 +01:00
Leonard Gram
c823ad5de7 team: uses PermissionType instead of int64 for permissions. 2019-03-19 14:01:13 +01:00
Leonard Gram
21d3d27452 teams: editors can't remove the last admin from a team. 2019-03-19 14:01:13 +01:00
Leonard Gram
b783fa7039 team: renames teams.CanUpdate teamguardian.CanAdmin 2019-03-19 14:01:12 +01:00
Hugo Häggmark
a90b3e331e config: updated feature toggle name 2019-03-19 13:59:39 +01:00
Leonard Gram
a6a3d698da teams: cleanup. 2019-03-19 13:57:30 +01:00
Leonard Gram
0b209de5d1 dashboard: only admin permission added to dashboard in folder. 2019-03-19 13:57:30 +01:00
Leonard Gram
d593ffe3c1 dashboards: better error handling 2019-03-19 13:57:30 +01:00
Leonard Gram
89d4db8eb6 teams: team listing shows only your teams (editors). 2019-03-19 13:57:29 +01:00
Leonard Gram
1f949e58e1 teams: teams guard on all teams update methods. 2019-03-19 13:57:29 +01:00
Leonard Gram
23231e6d51 teams: added delete team guard 2019-03-19 13:57:29 +01:00
Leonard Gram
8e7a8282c1 teams: removed feature toggle as it is already in middleware 2019-03-19 13:57:28 +01:00
Leonard Gram
d668550aa2 teams: added feature toggle and refactor tests 2019-03-19 13:57:28 +01:00
Leonard Gram
0d61f89577 teams: cleanup. 2019-03-19 13:57:28 +01:00
Leonard Gram
3be1d71f1f teams: test refactorings. 2019-03-19 13:57:27 +01:00
Leonard Gram
319879cfa8 teams: bugfix, user pointer. 2019-03-19 13:57:27 +01:00
Leonard Gram
90e9fda90c teams: start of team update guardian for editors 2019-03-19 13:57:26 +01:00
Hugo Häggmark
5adde259d3 teams: team update test 2019-03-19 13:57:26 +01:00
Hugo Häggmark
3c46b786d2 teams: change back to permissionlevel for Member to 0 2019-03-19 13:57:26 +01:00
Hugo Häggmark
3c74ac3044 teams: update only the selected user 2019-03-19 13:57:25 +01:00
Hugo Häggmark
074ebf0f48 teams: only write error message if error 2019-03-19 13:57:25 +01:00
Leonard Gram
aedc478208 teams: test for update team member. 2019-03-19 13:57:24 +01:00
Leonard Gram
2a88052c14 teams: can update team members permission. 2019-03-19 13:57:23 +01:00
Hugo Häggmark
7888457aae teams: basic ui for permission in team members view 2019-03-19 13:57:23 +01:00
Leonard Gram
af4994ba16 teams: editor added as admin for created teams. 2019-03-19 13:57:22 +01:00
Leonard Gram
22e098b830 teams: editors can work with teams. 2019-03-19 13:57:22 +01:00
Hugo Häggmark
efbd93f824 teams: show teams and plugins for editors that can own 2019-03-19 13:57:22 +01:00
Hugo Häggmark
124fb743e8 teams: make test cases pass again 2019-03-19 13:57:21 +01:00
Leonard Gram
da3dcd1918 folder: uses service to make user admin of created folder. 2019-03-19 13:57:21 +01:00
Leonard Gram
c8c004095c permissions: broken out func for making creator admin. 2019-03-19 13:57:21 +01:00
Leonard Gram
e174f7c20b folders: admin for created folders 2019-03-19 13:57:20 +01:00
Leonard Gram
e294252e92 dashboards: user automatically becomes admin for created dashboards 2019-03-19 13:57:20 +01:00
ryan
bd811b4a95 dont test exists in the test... it will fail if not found 2019-03-15 12:36:55 -07:00
ryan
24ead3a4a4 add random_walk_table scenario 2019-03-15 12:33:45 -07:00
ryan
2b5ac6bafa add test file 2019-03-15 11:07:20 -07:00
ryan
e787176bca add startAt to random walk scenario 2019-03-15 11:02:41 -07:00
Andrej Ocenas
09b9b595b2 Add check for Env before log 2019-03-15 11:53:30 +01:00
Sean Lafferty
3f9a19dcd5 Merge branch 'master' into 12556-oauth-pass-thru 2019-03-14 13:18:00 -04:00
Andrej Ocenas
8221c4273f
Merge pull request #15998 from grafana/add-grafana-user-proxy-header
Add custom header with grafana user when using proxy
2019-03-14 17:29:06 +01:00
Carl Bergquist
23852b59c9
Merge pull request #15839 from grafana/15836_revoke_auth_tokens
Support list and revoke of user auth tokens in HTTP API
2019-03-14 17:12:49 +01:00
Andrej Ocenas
697a87b7b2 Add check so that header is not sent for anonymous users 2019-03-14 16:33:21 +01:00
Andrej Ocenas
bbdc1c0e64 Add custom header with grafana user and a config switch for it 2019-03-14 16:33:19 +01:00
Carl Bergquist
291ffcb75b
Merge pull request #15457 from bergquist/distributed_cache
Distributed cache
2019-03-14 16:16:39 +01:00
bergquist
6d42d43b22 use constants for cache type 2019-03-14 15:48:20 +01:00
Sean Lafferty
f3c52710df Make recently used auth_module test more robust by adding another 'log in' 2019-03-14 08:40:19 -04:00
bergquist
0a86a1d7b6 updates old distcache names 2019-03-14 09:23:35 +01:00
bergquist
c001cfe1d9 dont allow inifinite expiration 2019-03-14 09:22:03 +01:00
bergquist
5186273731 return error if cache type is invalid 2019-03-14 08:57:38 +01:00
zhulongcheng
755f60358b Add more info to victorOps alert notifications 2019-03-14 15:47:11 +08:00
Sean Lafferty
fcc18d8121 Change import path for social in the tests 2019-03-13 14:55:22 -04:00
Sean Lafferty
8d8119aa98 Change import path for social since it has moved 2019-03-13 14:34:55 -04:00
Sean Lafferty
8d19ca005f Merge branch 'master' into 12556-oauth-pass-thru 2019-03-13 14:25:43 -04:00
Sean Lafferty
de338338bf Remove todo about index on user_id in user_auth because it exists 2019-03-13 13:46:49 -04:00
Sean Lafferty
7e62394d01 Add function in ds_proxy to handle oauthPassThru headers 2019-03-13 13:45:32 -04:00
Sean Lafferty
4324a7f51a Remove auth module from ds_proxy oauth test 2019-03-13 13:28:49 -04:00
Sean Lafferty
3b15e110a5 Get most recent oauth token from db, rather than lookup by auth_module 2019-03-13 13:22:22 -04:00
Sean Lafferty
f17307bb97 Always return most recently used auth_module from GetAuthInfo 2019-03-13 11:29:13 -04:00
Torkel Ödegaard
9e7d1f4275
Merge pull request #15466 from grafana/bar-gauge-poc
New Bar Gauge panel
2019-03-13 11:12:33 +01:00
bergquist
f13263eb54 reduce loglevel to debug 2019-03-13 09:01:45 +01:00
Torkel Ödegaard
71159fb606 Merge remote-tracking branch 'origin/master' into bar-gauge-poc 2019-03-13 08:26:06 +01:00
Sean Lafferty
d922285ab8 Move oauth token migrations in user_auth_mig 2019-03-11 09:31:03 -04:00
Torkel Ödegaard
647cb6ddae Merge branch 'master' of https://github.com/joshuawoodward/grafana into joshuawoodward-master 2019-03-11 13:10:45 +01:00
bergquist
7aeab0a235 use Get instead of Find 2019-03-11 11:04:56 +01:00
Torkel Ödegaard
90a3bc2203
Merge pull request #15892 from sandlis/14706-es-weekly-pattern-fix
Fix: #14706 Incorrect index pattern padding in alerting queries
2019-03-11 11:01:22 +01:00
Torkel Ödegaard
5fab1e89d3
Merge pull request #15897 from grafana/revert-15608-fix-datasource-update
Revert "Fix Datasource Update to no User/Password"
2019-03-11 10:58:28 +01:00
bergquist
b2967fbb37 avoid exposing cache client directly 2019-03-11 10:49:56 +01:00
bergquist
7e7427637c renames distcache -> remotecache 2019-03-11 10:49:55 +01:00
bergquist
66e71b66dd renames key to cache_key
apparently key is a reserved keyword in mysql.
and the error messages doesnt mention that.
can I please have 6h back?
2019-03-11 10:49:55 +01:00
bergquist
daa3b17951 code layouts and comments 2019-03-11 10:49:42 +01:00