Commit Graph

2649 Commits

Author SHA1 Message Date
Gabriel MABILLE
6fbf346747
AccessControl: Add endpoint to get user permissions (#45309)
* AccessControl: Add endpoint to get user permissions

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
Co-authored-by: Kalle Persson <kalle.persson@grafana.com>
Co-authored-by: Eric Leijonmarck <eric.leijonmarck@gmail.com>
Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>

* Fix SA tests

* Linter is wrong :p

* Wait I was wrong

* Adding the route for teams:creator too

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
Co-authored-by: Kalle Persson <kalle.persson@grafana.com>
Co-authored-by: Eric Leijonmarck <eric.leijonmarck@gmail.com>
Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>
2022-02-11 17:40:43 +01:00
Marcus Efraimsson
6a776c78d4
Datasource: Fixes storing of secureJSONData when creating/updating datasource (#45290)
Fixes an issue introduced by #44987 where bus dispatch was replaced by calling sqlstore 
directly instead of the datasource service.

Fixes #45273
2022-02-11 15:52:14 +01:00
Ieva
6fb3aac2e1
Access control: team UI improvements with FGAC (#45255)
* show teams page for user who can't list teams but can create teams

* Fixing buttons and routes

* Small refactor

Co-authored-by: gamab <gabi.mabs@gmail.com>
2022-02-11 09:58:37 +00:00
Ieva
9fafbfc87e
add the permission to read org users to team creator (#45224) 2022-02-10 14:51:05 +00:00
ying-jeanne
5ded070aab
dashdiff bus removal (#45175) 2022-02-10 16:58:52 +08:00
Gabriel MABILLE
78fc0258b1
AccessControl: Implement SQL filters for team members filtering (#44898)
* AccessControl: Filter team members

* Modify GetTeamMembersByUser comment

* Fix postgres failing test due to quoting

* Rename GetTeamMembersByUser to GetUserTeamMemberships

* Update TeamStore interface
2022-02-09 17:46:37 +01:00
Will Browne
3fbe4801b7
Plugins: Update collect metrics handler to latest signature (#45166)
* use updated collect metrics handler

* use proto helper
2022-02-09 17:36:53 +01:00
ying-jeanne
78eb06ec02
remove bus from login (#44995)
* remove bus from login

* remove comments and format correctly

* remove the downcast
2022-02-09 17:17:09 +01:00
Gabriel MABILLE
01b88adb3a
AccessControl: SQL filters for team search (#44557)
* AccessControl: SQL filters for team search

Set test config

* Remove userIdFilter when FGAC is on
2022-02-09 16:17:31 +01:00
idafurjes
df282a42cb
Remove bus from datasource api (#44987)
* Remove bus from datasource api

* Add DatasourcePermissionService and use it in api

* Fix wire and rename

* Fix import in wire

* Fix bug

* Rename Service to OSS service

* Roll back fix
2022-02-09 14:01:32 +01:00
Dimitris Sotirakis
605d056136
Security: Sync security changes on main (#45083)
* * Teams: Appropriately apply user id filter in /api/teams/:id and /api/teams/search
* Teams: Ensure that users searching for teams are only able see teams they have access to
* Teams: Require teamGuardian admin privileges to list team members
* Teams: Prevent org viewers from administering teams
* Teams: Add org_id condition to team count query
* Teams: clarify permission requirements in teams api docs
* Teams: expand scenarios for team search tests
* Teams: mock teamGuardian in tests

Co-authored-by: Dan Cech <dcech@grafana.com>

* remove duplicate WHERE statement

* Fix for CVE-2022-21702

(cherry picked from commit 202d7c190082c094bc1dc13f7fe9464746c37f9e)

* Lint and test fixes

(cherry picked from commit 3e6b67d5504abf4a1d7b8d621f04d062c048e981)

* check content type properly

(cherry picked from commit 70b4458892bf2f776302720c10d24c9ff34edd98)

* basic csrf origin check

(cherry picked from commit 3adaa5ff39832364f6390881fb5b42ad47df92e1)

* compare origin to host

(cherry picked from commit 5443892699e8ed42836bb2b9a44744ff3e970f42)

* simplify url parsing

(cherry picked from commit b2ffbc9513fed75468628370a48b929d30af2b1d)

* check csrf for GET requests, only compare origin

(cherry picked from commit 8b81dc12d8f8a1f07852809c5b4d44f0f0b1d709)

* parse content type properly

(cherry picked from commit 16f76f4902e6f2188bea9606c68b551af186bdc0)

* mentioned get in the comment

(cherry picked from commit a7e61811ef8ae558ce721e2e3fed04ce7a5a5345)

* add content-type: application/json to test HTTP requests

* fix pluginproxy test

* Fix linter when comparing errors

Co-authored-by: Kevin Minehart <kmineh0151@gmail.com>
Co-authored-by: Dan Cech <dcech@grafana.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Serge Zaitsev <serge.zaitsev@grafana.com>
Co-authored-by: Vardan Torosyan <vardants@gmail.com>
2022-02-09 13:44:38 +01:00
ying-jeanne
ef11e783f1
ldap debug bus removal (#45014)
* ldap debug bus removal

* linter
2022-02-09 11:45:31 +01:00
Artur Wierzbicki
a025109647
Dash previews: populate crawler queue from SQL query (#44083)
* add SQL migrations

* dashboard previews from sql: poc

* added todos

* refactor: use the same enums where possible

* use useEffect, always return json

* added todo

* refactor + delete files after use

* refactor + fix manual thumbnail upload

* refactor: move all interactions with sqlStore to thumbnail repo

* refactor: remove file operations in thumb crawler/service

* refactor: fix dashboard_thumbs sql store

* refactor: extracted thumbnail fetching/updating to a hook

* refactor: store thumbnails in redux store

* refactor: store thumbnails in redux store

* refactor: private'd repo methods

* removed redux storage, saving images as blobs

* allow for configurable rendering timeouts

* added 1) query for dashboards with stale thumbnails, 2) command for marking thumbnails as stale

* use sql-based queue in crawler

* ui for marking thumbnails as stale

* replaced `stale` boolean prop with `state` enum

* introduce rendering session

* compilation errors

* fix crawler stop button

* rename thumbnail state frozen to locked

* #44449: fix merge conflicts

* #44449: remove thumb methods from `Store` interface

* #44449: clean filepath, defer file closing

* #44449: fix rendering.Theme cyclic import

* #44449: linting

* #44449: linting

* #44449: mutex'd crawlerStatus access

* #44449: added integration tests for `sqlstore.dashboard_thumbs`

* #44449: added comments to explain the `ThumbnailState` enum

* #44449: use os.ReadFile rather then os.Open

* #44449: always enable dashboardPreviews feature during integration tests

* #44449: remove sleep time, adjust number of threads

* #44449: review fix: add `orgId` to `DashboardThumbnailMeta`

* #44449: review fix: automatic parsing of thumbnailState

* #44449: lint fixes

* #44449: review fix: prefer `WithDbSession` over `WithTransactionalDbSession`

* #44449: review fix: add a comment explaining source of the filepath

* #44449: review fix: added filepath validation

* #44449: review fixes https://github.com/grafana/grafana/pull/45063/files @fzambia

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
Co-authored-by: Alexander Emelin <frvzmb@gmail.com>
2022-02-09 13:23:32 +04:00
ying-jeanne
38f93d675b
dashboard snapshot bus removal (#44956) 2022-02-08 17:57:59 +01:00
Sofia Papagiannaki
35fe58de37
API: Extract OpenAPI specification from source code using go-swagger (#40528)
* API: Using go-swagger for extracting OpenAPI specification from source code

* Merge Grafana Alerting spec

* Include enterprise endpoints (if enabled)

* Serve SwaggerUI under feature flag

* Fix building dev docker images

* Configure swaggerUI

* Add missing json tags

Co-authored-by: Ying WANG <ying.wang@grafana.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2022-02-08 13:38:43 +01:00
Marcus Efraimsson
05ea825c76
Chore: Logging improvements (#44925)
Fixing a couple bugs, adds some tests and hopefully decrease 
lock contention when logging.
Switching from using sync.RWMutex to go-kit SwapLogger.
Fixes bug when creating a new logger from an existing one that 
screwed up the keyvals and/or lost the logger name. 

Ref #44681
2022-02-07 16:00:08 +01:00
J Guerreiro
94820e1f29
Add/Delete API keys to Service accounts (#44871)
* ServiceAccounts: move token handlers to specific file

* ServiceAccounts: move Add API key to Service account

* APIKeys: api keys can still be used even when service accounts are enabled

* APIKeys: legacy endpoint can't be used to add SA tokens

* ServiceAccount: add tests for creation with nil and non-nil service account ids

* ServiceAccounts: fix unnasigned cfg and AC typo

* Test: test service account token adding

* fix linting error

* ServiceAccounts: Handle Token deletion

* rename token funcs

* rename token funcs and api wrapping

* add token deletion tests

* review

Co-authored-by: eleijonmarck <eric.leijonmarck@gmail.com>

* remove bus

* Update pkg/api/apikey.go

Co-authored-by: eleijonmarck <eric.leijonmarck@gmail.com>
2022-02-07 14:51:54 +01:00
ying-jeanne
016fa77460
remove bus from loginservice (#44907) 2022-02-07 14:36:15 +01:00
ying-jeanne
69c764897e
remove dispatch from apikey (#44955) 2022-02-07 21:14:54 +08:00
idafurjes
caa5f356be
Remove bus from dashboard api (#44923)
* Remove bus from dashboard api

* Polish api dashboard tests

* Remove Delete Slug method

* Fix sqlstore dashboard test

* Remove bus from dashboard permission

* Remove GetDashboardsBySlug from sqlstore
2022-02-07 12:43:43 +01:00
Kat Yang
7105bb3be7
Chore: Remove bus from admin users (#44869)
* Chore: Remove bus from admin users

* Mock authinfoservice

* Update user id

* attempt to fix the tests in admin users api

* fix type cast

* revert skipped tests

Co-authored-by: Serge Zaitsev <serge.zaitsev@grafana.com>
2022-02-04 13:45:42 -05:00
Will Browne
126ed461b1
remove grafana specific config from package (#44866) 2022-02-04 18:14:53 +01:00
Kat Yang
5c87044aa2
Chore: Remove bus from frontend settings (#44921) 2022-02-04 17:55:50 +01:00
Kat Yang
0e6300fb49
Chore: Remove bus from admin (#44920)
* Chore: Remove bus from admin

* fix test

Co-authored-by: Ying WANG <ying.wang@grafana.com>
2022-02-04 17:53:58 +01:00
Serge Zaitsev
9d654bb6b8
Chore: Remove bus from plugin proxy api (#44899)
* remove bus from plugin proxy api

* fixing the tests
2022-02-04 17:35:00 +01:00
Serge Zaitsev
61533a3cb4
Chore: Remove bus from health api (#44897)
* remove bus from health api

* fix health api tests

* use db health query as a method

* use pointer in sqlstore mock
2022-02-04 14:33:35 +01:00
Serge Zaitsev
058e3ffc21
Chore: Remove bus from Alerting API (#44894)
* assign handlers to httpserver

* turn sqlstore mock in to a pointer

* add search service interface

* fix tests for alerting and other apis

* once again, make linter happy
2022-02-04 13:41:15 +01:00
ying-jeanne
c5211f848d
remove bus from search service (#44825) 2022-02-03 18:46:38 +01:00
Selene
3ce0730558
AuthService: Move database logic to its own class and package (#44835)
* Move database logic to its own class and package

* Fix lint
2022-02-03 18:23:45 +01:00
Kat Yang
9b3cb4a306
Chore: Remove bus from index (#44851) 2022-02-03 18:22:21 +01:00
Gabriel MABILLE
8217d6d206
AccessControl: Change teams permissions page when accesscontrol is enabled (#43971)
* AccessControl: Change teams permissions page when frontend is hit

* Implement frontend changes for group sync

* Changing the org/teams/edit permissions

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>

* Fixing routes

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>

* Use props straight away no need to go through the state

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>

* Update public/app/features/teams/TeamPages.tsx

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2022-02-03 17:49:39 +01:00
Ieva
602d62ebcc
Access control: FGAC for team sync endpoints (#44673)
* add actions for team group sync

* extend the hook to allow specifying whether the user is external

* move user struct to type package

* interface for permission service to allow mocking it

* reuse existing permissions

* test fix

* refactor

* linting
2022-02-03 15:27:05 +00:00
Marcus Efraimsson
bc7e55d99b
Chore: Fix log filters (#44681) 2022-02-03 23:20:02 +08:00
Alex Khomenko
a79c048344
Feature Highlights: move setting to a feature toggle (#44780)
* Add toggle

* Use the toggle

* Cleanup
2022-02-03 13:53:23 +02:00
Kat Yang
f582e6c86a
Chore: Remove bus from password (#44482)
* Chore: Remove bus from password

* Refactor: Remove bus from password.go and adjust tests

* remove sqlstore dependency from notifications

* Chore: Remove bus from password

* Refactor: Remove bus from password.go and adjust tests

* remove sqlstore dependency (again)

* remove fmt printf

* fix dependencies in http server

* fix renamed method in tests

Co-authored-by: Serge Zaitsev <serge.zaitsev@grafana.com>
2022-02-03 10:33:46 +01:00
Vardan Torosyan
f38f10416a
Revert fixed roles and service accounts (#44778)
* Revert fixed roles and service accounts

* Leave the fixed role for service accounts
2022-02-03 09:59:26 +01:00
idafurjes
1b286e6bb5
Remove bus from quota, preferences, plugins, user_token (#44762)
* Remove bus from quota, preferences, plugins, user_token

* Bind sqlstore.Store to *sqlstore.SQLStore

* Fix test

* Fix sqlstore wire injection, dependency
2022-02-03 09:20:20 +01:00
Marcus Efraimsson
0092d10764
Instrumentation: Fix HTTP request instrumentation of authentication failures (#44234)
Moves the request tracing middleware earlier in the chain, just after the tracing middleware 
and before the log middleware. With these changes we'll be able to track 
authentication/authorization status failures that currently exits early and don't execute the 
request tracing middleware. In addition, there might be some other routes now being tracked 
with this that we didn't do before.

Fixes #39590
2022-02-02 18:48:46 +01:00
Eric Leijonmarck
1dd2579528
fix: remove migrated, and /org endpoint (#44788)
* fix: remove migrated, and /org endpoint

* Update pkg/api/index.go
2022-02-02 16:32:37 +01:00
Ieva
9247848a7b
increment fixed role version (#44779) 2022-02-02 15:24:16 +00:00
Konrad Lalik
69e4796504
Alerting: Split legacy and unified routing configuration (#44641)
* Disable add alert menu entry for legacy alerting

* Split legacy and unified routing configuration

* Fix fallback routes configuration
2022-02-02 10:57:43 +01:00
Karl Persson
e93e1bdd2b
Access control: Enable data source view for partial permissions (#44695)
* Return correct value

* Remove scope all requirement

* Only add dashboard sub nav if user is admin
2022-02-01 15:00:05 +01:00
Selene
875e0736ec
LDAP: Use an interface instead of a bus to get group teams (#42165)
* Remove bus for GetTeams for LDAP

* Fix lint
2022-02-01 12:03:21 +01:00
idafurjes
12420260ef
Remove bus from org invite api (#44530)
* Remove bus from org invite api

* Fix lint

* Remove comment
2022-01-31 17:24:52 +01:00
Santiago
7ed82ac049
Check for empty URLs when creating/updating a data source (#42837)
* checks for empty URLs added

* check for TimeSeriesTypeNot to fix InfluxDB alerts

* log a warning when a data frame is ignored

* fix: add brittle Prometheus URL input selector

needs a proper aria-label or test-data-id selector

* test: add URL input aria-label

needs to use the grafana/e2e-selectors package

* test: run ci

* add URL validation for specific data sources, e2e tests

* Update pkg/api/datasource/validation.go

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>

* delete duplicated logs

* delete unnecessary leading newline

Co-authored-by: gillesdemey <gilles.de.mey@gmail.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2022-01-31 12:39:55 -03:00
Karl Persson
5ca9d2895b
Add viewer grant to fixed:datasources:reader if viewers_can_edit is set to true (#44657) 2022-01-31 16:33:41 +01:00
Will Browne
76603b93d6
Plugins: Refactor Grafana and Plugin version update checkers (#44529)
* refactor

* rework plugin update checking

* make smarter

* simplify

* fix linter issue

* make use of mutex

* apply feedback to simplify

* format imports

* fix tests
2022-01-31 16:06:16 +01:00
Josh Hunt
c6ce629fd8
I18n: Translate navigation items (#44131)
* I18n: Translate navigation items

* improve comment, remove console.log

* update mock macros

* Mark up all phrases for translation

* added deprecate text comment, moved translations to a seperate file

* use TestProvider in NavBarItem

* use TestProvider in nav tests

* remove text deprecation comment

* update translations
2022-01-31 03:41:58 +01:00
Ivana Huckova
4e37a53a1c
Query history: Create API to add query to query history (#44479)
* Create config to enable/disable query history

* Create add to query history functionality

* Add documentation

* Add test

* Refactor

* Add test

* Fix built errors and linting errors

* Refactor

* Remove old tests

* Refactor, adjust based on feedback, add new test

* Update default value
2022-01-28 17:55:09 +01:00
Karl Persson
e844b263c7
Access control: Load permissions from memory and database (#42080)
* Load permission from both in memory and from database
Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2022-01-28 16:11:18 +01:00
J Guerreiro
312dd9e315
AccessControl: Add AC to team preferences (#44554)
* AccessControl: Add AC to team preferences

* Apply suggestions from code review

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2022-01-28 12:17:54 +01:00
Marcus Efraimsson
94edd7a762
Plugins: Refactor plugin dashboards (#44315)
Moves/refactor Grafana specific functionality related to plugin dashboards 
out to specific services for importing dashboards and keep app plugin dashboards
up-to-date.

Fixes #44257
2022-01-28 10:28:33 +01:00
Will Browne
b5dd4842d0
Plugins: Make manager more easily composable (#44467)
* make more easily composable

* fix build
2022-01-27 18:06:38 +01:00
Todd Treece
4d1f3a3f6c
Recorded Queries: Enable by default (#44397) 2022-01-27 11:09:39 -05:00
J Guerreiro
cb6e5ae8ce
AccessControl: Add access control actions and scopes to team update and delete
* AccessControl: Add access control actions and scopes to team update and delete

* AccessControl: Add tests for AC guards in update/delete

* AccessControl: add fixed role for team writer

* AccessControl: ensure team related AC is deleted with team

* Update pkg/api/team_test.go
2022-01-27 16:16:44 +01:00
idafurjes
82892331c1
Chore: Remove bus from signup and playlist api (#44485)
* Remove bus from signup and playlist api

* Remove bus from playlist play
2022-01-27 10:33:02 +01:00
Artur Wierzbicki
5148250366
Rendering service - add optional RenderingSession (#44098)
* rendering service changes:
- make node-renderer request timeout configurable
- introduce optional RenderingSession providing a long-lived session key

* remove console logs

* added comment explaining empty "afterRequest" method

* fix compilation error

* update imports formatting

* Update pkg/services/rendering/interface.go

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>

* Update pkg/services/rendering/rendering.go

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>

* review fix: extract renderKey related functions/structs to auth.go

* #44449: private'd `rendering.getRequestTimeout`

Co-authored-by: Agnès Toulet <35176601+AgnesToulet@users.noreply.github.com>
2022-01-27 02:02:19 +04:00
idafurjes
58ee553634
Chore: Remove bus from user api (#44468)
* Chore: Remove bus from user api

* Adu authinfoservice interface

* User authinfoservice.Service instead of authinfoservice.Implementation in HTTPServer

* Rename Implementation to authInfoService
2022-01-26 20:24:05 +01:00
Ryan McKinley
5d66194ec5
FeatureFlags: define features outside settings.Cfg (take 3) (#44443) 2022-01-26 09:44:20 -08:00
Gabriel MABILLE
d4f682190f
AccessControl: Implement teams resource service (#43951)
* AccessControl: cover team permissions

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>

* Add background service as a consumer to resource_services

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>

* Define actions in roles.go

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>

* Remove action from accesscontrol model

 Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>

* As suggested by kalle

* move some changes from branch to the skeleton PR

* Add background service as a consumer to resource_services

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>

* moving resourceservice to the main wire file pt2

* move team related actions so that they can be reused

* PR feedback

* fix

* typo

* Access Control: adding hooks for team member endpoints (#43991)

* AccessControl: cover team permissions

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>

* Add background service as a consumer to resource_services

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>

* Define actions in roles.go

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>

* Remove action from accesscontrol model

 Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>

* As suggested by kalle

* add access control to list and add team member endpoint, and hooks for adding team members

* member permission type is 0

* add ID scope for team permission checks

* add more team actions, use Member for member permission name

* protect team member update endpoint with FGAC permissions

* update SQL functions for teams and the corresponding tests

* also protect team member removal endpoint with FGAC permissions and add a hook to permission service

* a few small fixes, provide team permission service to test setup

* AccessControl: cover team permissions

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>

* Add background service as a consumer to resource_services

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>

* Define actions in roles.go

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>

* Remove action from accesscontrol model

 Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>

* As suggested by kalle

* move some changes from branch to the skeleton PR

* remove resource services from wireexts

* remove unneeded actions

* linting fix

* remove comments

* feedback fixes

* feedback

* simplifying

* remove team member within the same transaction

* fix a mistake with the error

* call the correct sql fction

* linting

* Access control: tests for team member endpoints (#44177)

* tests for team member endpoints

* clean up and fix the tests

* fixing tests take 2

* don't import enterprise test license

* don't import enterprise test license

* remove unused variable

Co-authored-by: gamab <gabi.mabs@gmail.com>
Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
2022-01-26 14:48:41 +00:00
Katarina Yang
92ca38bedf
Refactor: Change sqlstore.inTransaction to SQLStore.WithTransactionalDBSession in misc files (#43926)
* Refactor: Change sqlstore.inTransaction to SQLStore.WithTransactionalDBSession in misc files

* Refactor: Change .inTransaction in org.go file

* Refactor: Update init() to proper SQLStore handlers

* Refactor: Update funcs in tests to be sqlStore methods

* Refactor: Update API funcs to receive HTTPServer

* Fix: define methods on sqlstore

* Adjust GetSignedInUser calls

* Refactor: Add sqlStore to Service struct

* Chore: Add back black spaces to remove file from PR

Co-authored-by: Ida Furjesova <ida.furjesova@grafana.com>
2022-01-25 20:30:08 +01:00
Alex Khomenko
aead2e9157
Navigation: allow adding extra content (#44048)
* Add PRO badge

* Allow adding extra content

* Add extra content for the new navbar

* Use highlight text instead of extra content

* Trigger extra events

* Remove ExtraContent

* Update public/app/core/components/NavBar/NavFeatureHighlight.tsx

Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>

* Remove redundant i

* Add UpgradeBox

* Move highlight to menu trigger

* Clear navbar next

* Cleanup

* Fix UpgradeBox styles

* Add arrow icon

Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
2022-01-25 10:04:44 +02:00
idafurjes
dbb2d3af73
Chore: Fix attribute value (#44368)
* Fix attribute value

* Fix also the value for opentracing
2022-01-24 18:17:39 +01:00
Agnès Toulet
65bdb3a899
FeatureFlags: Revert managing feature flags outside of settings.Cfg (#44382)
* Revert "FeatureToggles: register all enterprise feature toggles (#44336)"

This reverts commit f53b3fb007.

* Revert "FeatureFlags: manage feature flags outside of settings.Cfg (#43692)"

This reverts commit f94c0decbd.
2022-01-24 16:08:05 +01:00
Guilherme Caulada
29268483c2
HTTPServer: Implement named middlewares (#44231)
* Implement named middlewares on http server

* Fix minor ordering issue with named middlewares
2022-01-24 10:41:18 -03:00
idafurjes
00c389933b
Chore: Remove bus from team (#44218)
* Remove bus from team

* Fix api team test

* Remove bus from team members
2022-01-24 11:52:35 +01:00
Jeff Levin
c8154b9fe2
Datasource API: #32556 resolve readonly datasources can be modified (#44186)
* Check if datasource is read-only when making an update
* Standardize api returning a 404 if datasource is not found while making an update

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>, Jesse Weaver<pianohacker@gmail.com>
2022-01-21 14:22:43 -09:00
Ryan McKinley
f94c0decbd
FeatureFlags: manage feature flags outside of settings.Cfg (#43692) 2022-01-20 13:42:05 -08:00
Isabella Siu
2c3bed1f4b
CloudWatch: remove unused "live" log code (#44185) 2022-01-20 08:58:39 -05:00
idafurjes
30aa24a183
Chore: Implement OpenTelemtry in Grafana (#42674)
* Separate Tracer interface to TracerService and Tracer

* Fix lint

* Fix:Make it possible to start spans for both opentracing and opentelemetry in ds proxy

* Add span methods, use span interface for rest of tracing

* Fix logs in tracing

* Fix tests that are related to tracing

* Fix resourcepermissions test

* Fix some tests

* Fix more tests

* Add TracingService to wire cli runner

* Remove GlobalTracer from bus

* Renaming test function

* Remove GlobalTracer from TSDB

* Replace GlobalTracer in api

* Adjust tests to the InitializeForTests func

* Remove GlobalTracer from services

* Remove GlobalTracer

* Remove bus.NewTest

* Remove Tracer interface

* Add InitializeForBus

* Simplify tests

* Clean up tests

* Rename TracerService to Tracer

* Update pkg/middleware/request_tracing.go

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>

* Initialize tracer before passing it to SQLStore initialization in commands

* Remove tests for opentracing

* Set span attributes correctly, remove unnecessary trace initiliazation form test

* Add tracer instance to newSQLStore

* Fix changes due to rebase

* Add modified tracing middleware test

* Fix opentracing implementation tags

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2022-01-20 11:10:12 +01:00
Eric Leijonmarck
bf4c217b95
Serviceaccounts: refactor list using server admin page (#44122)
* refactor: use server admin listing serviceaccounts

Co-authored-by: Jguer <joao.guerreiro@grafana.com>

* setup route for specifc service account

* add routes to index

* main issue with spelling mistakes

* feat: make routes /serviceacconts/id for navModel

Co-authored-by: Jguer <joao.guerreiro@grafana.com>
Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>

* Update pkg/services/serviceaccounts/manager/service.go

Co-authored-by: Jguer <joao.guerreiro@grafana.com>
Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>
2022-01-19 17:03:45 +01:00
Gabriel MABILLE
54280fc9d7
AccessControl: Resolve attribute based scopes to id based scopes (#40742)
* AccessControl: POC scope attribute resolution

Refactor based on ScopeMutators

test errors and calls to cache

Add comments to tests

Rename logger

Create keywordMutator only once

* AccessControl: Add AttributeScopeResolver registration

Co-authored-by: gamab <gabriel.mabille@grafana.com>

* AccessControl: Add AttributeScopeResolver to datasources

Co-authored-by: gamab <gabriel.mabille@grafana.com>

* Test evaluation with translation

* fix imports

* AccessControl: Test attribute resolver

* Fix trailing white space

* Make ScopeResolver public for enterprise redefine

* Handle wildcard

Co-authored-by: Jguer <joao.guerreiro@grafana.com>

Co-authored-by: jguer <joao.guerreiro@grafana.com>
2022-01-18 17:34:35 +01:00
Karl Persson
f75e4d1a4f
Access Control: Allow signed in users access to GET data sources endpoints (#43338)
* remove scopes from endpoints and add datasources:read without scope to
the compatibility role
2022-01-17 10:16:12 +01:00
ying-jeanne
7422789ec7
Remove Macaron ParamsInt64 function from code base (#43810)
* draft commit

* change all calls

* Compilation errors
2022-01-15 00:55:57 +08:00
Karl Persson
f999910dc6
Access control: Add access control sql filter to org user queries (#43961)
* Add access control SQL filter to org user queries
2022-01-13 14:40:32 +01:00
Jeremy Price
e894837b7e
Accesscontrol: Remove service account creation code from addapikey (#43900)
* Remove service account creation code from addapikey
Co-authored-by: J Guerreiro <joao.guerreiro@grafana.com>
2022-01-12 15:18:57 +01:00
Sofia Papagiannaki
963ae4ef87
API: Fix storing dashboard with static UID (#43861)
* API: Fix storing dashboard with static UID
2022-01-11 18:39:53 +02:00
Ieva
a06564fb0d
Access control: allow granting a fixed role dynamically based on the startup settings (#43867)
* allow granting a fixed role dynamically depending on startup config

* move role definition for team writing

* undo test changes

* nicer naming
2022-01-11 11:58:40 +01:00
Ieva
41b709d08d
Access control: permissions for team creation (#43506)
* FGAC for team creation

* tests

* fix snapshot for UI tests

* linting

* update snapshots

* Remove unecessary class and update tests

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>

* Make the condition slightly easier

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>

Co-authored-by: gamab <gabi.mabs@gmail.com>
2022-01-10 17:05:53 +00:00
Ryan McKinley
b404aae9c3
Crawler: use existing render service to generate dashboard thumbnails (#43515)
Co-authored-by: Artur Wierzbicki <artur@arturwierzbicki.com>
2022-01-10 08:21:35 -08:00
Dan Cech
34f757ba5a
switch to using featureEnabled for enterprise features (#41559)
* switch to using featureEnabled for enterprise features
2022-01-07 15:11:23 -05:00
Selene
32ed680fc2
Team Guardian: Refactor it to remove the bus dependency (#43058)
* Refactor team guardian to avoid to use bus

* Fix lint

* Fix lint
2022-01-07 13:38:00 +01:00
ying-jeanne
a8eef45a44
Logger migration from log15 to gokit/log (#41636)
* migrate log15 to gokit/log

* fix console log

* update some unittest

* fix all unittest

* fix the build

* Update pkg/infra/log/log.go

Co-authored-by: Yuriy Tseretyan <tceretian@gmail.com>

* general type vector

* correct the level key

Co-authored-by: Yuriy Tseretyan <tceretian@gmail.com>
2022-01-06 22:28:05 +08:00
J Guerreiro
6bbf85e2e9
AccessControl: verify metadata map is not null (#43743) 2022-01-06 11:54:51 +01:00
Gabriel MABILLE
92c568e9f7
AccessControl: Remove unused error from GetResourcesMetadata (#43710)
* AccessControl: Remove unused error from GetResourcesMetadata

Co-authored-by: J Guerreiro <joao.guerreiro@grafana.com>
2022-01-05 17:24:14 +01:00
Eric Leijonmarck
0aa905bb1f
Serviceaccounts: feat - tabview for serviceaccounts (#43573) 2022-01-05 15:32:38 +01:00
J Guerreiro
056e143664
AccessControl: Present user edit actions according to AC metadata (#43602)
* AccessControl: Add user metadata to user detail view

* AccessControl: Do not present delete or disable buttons based on ac metadata in admin/users

* AccessControl: do not allow password changing or user editing without permission

* AccessControl: Fetch global:users scope for admin

* AccessControl: optimize org.user metadata fetch

* Chore: early return if ac metadata is not available
2022-01-05 09:59:17 +01:00
Jeremy Price
42ccc44eca
Accesscontrol: Apply FGAC to APIKey endpoints (#42659)
* Move definitions to serviceaccounts

* Use constant names, add scope to delete

* Add descriptions to roles

* Rename roles
2022-01-04 15:37:40 +01:00
idafurjes
65e60759fb
Rename AddEventListenerCtx to AddEventListener and PublishCtx to Publish (#43566) 2022-01-04 09:36:01 +01:00
idafurjes
8e6d6af744
Rename DispatchCtx to Dispatch (#43563) 2021-12-28 17:36:22 +01:00
idafurjes
7936c4c522
Rename AddHandlerCtx to AddHandler (#43557) 2021-12-28 16:08:07 +01:00
idafurjes
56c3875bb9
Chore: Remove context.TODO (#43458)
* Remove context.TODO() from services

* Fix live test
2021-12-28 10:26:18 +01:00
Alex Khomenko
3b4a4be3c6
Feature highlights: add setting toggle (#43394)
* Feature highlights: add toggle setting

* Settings: Use provider for 'feature_highlights' section

* Fix frontendsettings API tests

* Document the toggle

Co-authored-by: Joan López de la Franca Beltran <5459617+joanlopez@users.noreply.github.com>
Co-authored-by: Joan López de la Franca Beltran <joanjan14@gmail.com>
2021-12-24 10:49:52 +02:00
Ryan McKinley
4233a62aeb
DashboardPreviews: add dashboard previews behind feature flag (#43226)
Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
Co-authored-by: Artur Wierzbicki <artur@arturwierzbicki.com>
2021-12-23 09:43:53 -08:00
J Guerreiro
3d4fafcf70
AccessControl: Add access control metadata to org user DTOs (#43362)
* AccessControl: Add access control metadata to OrgUserDTO

* AccessControl: get User AC metadata

* AccessControl: return User Access Control metadata when requested
2021-12-22 18:46:33 +01:00
idafurjes
b8852ef6a3
Chore: Remove context.TODO() (#43409)
* Remove context.TODO() from services

* Fix live test

* Remove context.TODO
2021-12-22 11:02:42 +01:00
Sofia Papagiannaki
c4aaf5f9d1
API: prevent provisioned dashboard from being updated (#41894) 2021-12-17 10:31:52 -05:00
Jeremy Price
13fdc5231d
AccessControl: upgrade apikeys by adding service accounts (#42425)
Co-authored-by: Eric Leijonmarck <eric.leijonmarck@gmail.com>

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>

* Change default options for cloned service account

* Run in background

* Add endpoint to upgrade api keys to service accounts
2021-12-16 14:28:16 +01:00
Gabriel MABILLE
c7cabdfd6f
AccessControl: Add accesscontrol metadata to datasources DTOs (#42675)
* AccessControl: Provide scope to frontend

* Covering datasources with accesscontrol metadata

* Write benchmark tests for GetResourcesMetadata

* Add accesscontrol util and interface

* Add the hasPermissionInMetadata function in the frontend access control code

* Use IsDisabled rather that performing a feature toggle check

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
2021-12-15 12:08:15 +01:00
Ryan McKinley
c0ff685d3b
Live: support query execution with live RPC (#43118)
Co-authored-by: Alexander Emelin <frvzmb@gmail.com>
2021-12-14 18:38:20 +01:00
Karl Persson
9558c09a7c
Access Control: Store permissions on SignedInUser (#43040)
* add permission structure to signedinuser

* add middleware to load user permissions into signedinuser struct

* apply LoadPermissionsMiddleware to http server

* check for permissions in signedinuser struct

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2021-12-14 16:05:59 +01:00
Will Browne
e4ba5f17dd
add core plugins thru store (#43085) 2021-12-14 15:22:40 +01:00
Will Browne
155487bfb0
Plugins: Add typed models for frontend settings data sources and panels (#42062)
* add model for data source

* add model for panels

* add omitempty

* make consistent with main

* dont emit bools

* resolve conflicts

* remove file

* remove file

* update field name

* always pass jsonData

* minify the changes

* remove dupe line
2021-12-14 11:16:13 +01:00
Will Browne
6c4555265a
Plugins: Update client to use SDK resource contract (#42888)
* client uses sdk resource handler

* apply pr feedback
2021-12-14 11:15:49 +01:00
Serge Zaitsev
f5802878f1
Chore: Move remaining web framework code to pkg/web, remove macaron binding module (#43018)
* remove macaron binding dependency

* completely purge macaron binding

* move everything to pkg/web

* remove non-go files from pkg/web

* clean up leftovers of macaron imports

* make linter happy
2021-12-13 15:56:14 +01:00
Torkel Ödegaard
0e88f5db85
AppPlugins: Support app plugins with only default nav (#43016) 2021-12-13 14:06:15 +01:00
Marcus Efraimsson
d6ec6f8ad2
Backport fix to main (#42979)
* fixes

(cherry picked from commit a2c386915ce11b9422f4af8ae181eaa1a22bc5c3)
(cherry picked from commit 06706efbbe)

* fix regex

(cherry picked from commit a259213a3badc9618e969f2c8db0a0143f00faee)
(cherry picked from commit 1d7105c095)

* lint (#42970)

(cherry picked from commit afb9e8e5f3)

Co-authored-by: Will Browne <will.browne@grafana.com>
Co-authored-by: malcolmholmes <42545407+malcolmholmes@users.noreply.github.com>
2021-12-10 16:10:04 +01:00
Dimitris Sotirakis
c798c0e958
Security: Fix directory traversal issue (#42846)
* security: fix dir traversal issue

(cherry picked from commit 00e38ba555)

* Improve comments and error message.

Co-authored-by: Kyle Brandt <kyle@grafana.com>
2021-12-07 19:15:53 +02:00
William Assis
eab0ba8716
Analytics: RudderStack custom URLs to fetch SDK and Config (#41988)
* Add config options to provide custom URL to fetch Rudderstack SDK and Config

* Add new entries to defaults.ini

* Update docs
2021-12-06 09:42:29 -05:00
idafurjes
c80e7764d8
Chore: Remove Dispatch and AddHandler (#42603)
* Remove Dispatch

* Remove context.TODO()

* Remove AddHandler and Dispatch
2021-12-02 18:08:59 +01:00
David Parrott
a53b78df0c
Alerting: improve error on failure to remove query referenced by legacy alerting (#42169)
* Improve error and add test

* praise the linter!

* pr feedback

* guard against nil

* getters and setters

* Use IsEnabled instead of accessing struct
2021-12-02 07:41:24 -08:00
Piotr Jamróz
bb24e8d578
Chore: Report frontend metrics for JS/CSS load time (#42421)
* Report frontend metrics for js/css load time

* Add FCP metric

* Change comment

* Simplify reporting frontend metrics
2021-12-02 09:34:39 +01:00
idafurjes
9880a843ed
Add context to notifications (#42578) 2021-12-01 17:56:08 +01:00
idafurjes
d993b12415
Add interface Tracer, add Opentelemetry (#41963)
* Add interface Tracer, add Opentelemetry

* Fix lint

* Fix failing tests and return error if config not parsed fo opentelemetry

* Update defaults.ini

Add comment with jaeger url

* go mod tidy

* Remove comments that are not needed

* Move OpentracingSpan to tracing.go

* Add opentelemetry to sample.ini
2021-12-01 17:05:08 +01:00
idafurjes
e6123bc3ef
Replace AddHandler with AddHandlerCtx in tests (#42585) 2021-12-01 15:43:31 +01:00
Serge Zaitsev
95831e9be0
Fix: Restore data binding in the create dashboard handler 2021-11-29 19:05:20 +01:00
Will Browne
9c9e79da4f
only preload app plugins (#42434) 2021-11-29 18:26:04 +01:00
Alexander Zobnin
becfd776c3
OAuth: Forward id token to the data source (#42422)
* OAuth: Forward id token to the data source

* Add tests

* Forward id token in legacy API

* Check if id_token is string or not
2021-11-29 15:40:05 +01:00
idafurjes
a65e0be110
Replace AddEventListener with AddEventListenerCtx and Publish with PublishCtx (#42284) 2021-11-29 14:23:24 +01:00
Marcus Efraimsson
8927a3ca20
Chore: Query endpoint refactor (#41637)
Get rid of using legacydata.RequestHandler in HTTPServer, /api/tsdb/query and pkg/expr 
with the goal of deprecating /api/tsdb/query and remove it completely eventually. This is 
the first step of cleaning up the HTTP API query endpoint.

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Alexander Emelin <frvzmb@gmail.com>
2021-11-29 14:21:54 +01:00
Serge Zaitsev
d9cdcb550e
Chore: Refactor api handlers to use web.Bind (#42199)
* Chore: Refactor api handlers to use web.Bind

* fix comments

* fix comment

* trying to fix most of the tests and force routing.Wrap type check

* fix library panels tests

* fix frontend logging tests

* allow passing nil as a response to skip writing

* return nil instead of the response

* rewrite login handler function types

* remove handlerFuncCtx

* make linter happy

* remove old bindings from the libraryelements

* restore comments
2021-11-29 10:18:01 +01:00
idafurjes
725dbf8d95
Chore: Add context to datasource service (#42294)
* Add context to datasource service

* Adjust wire for ShouldBeReported method

* Replace inTransactionCtx
2021-11-26 18:10:36 +01:00
idafurjes
ac6867c3bb
Chore: Add context to authinfo (#42096)
* Add context to authinfo

* Replace Dispatch with DispatchCtx
2021-11-25 14:22:40 +01:00
Armand Grillet
6523486122
Alerting: Make Unified Alerting enabled by default for those who do not use legacy alerting (#42200)
* update AlertingEnabled and UnifiedAlertingSettings.Enabled to be pointers
* add a pseudo migration to fix the AlertingEnabled and UnifiedAlertingSettings.Enabled if the latter is not defined
* update the default configuration file to make default value for both 'enabled' flags be undefined

Misc
* update Migrator to expose DB engine. This is needed for a ualert migration to access the database while the list of migrations is created.
* add more verbose failure when migrations do not match

Co-authored-by: gotjosh <josue@grafana.com>
Co-authored-by: Yuriy Tseretyan <yuriy.tseretyan@grafana.com>
Co-authored-by: gillesdemey <gilles.de.mey@gmail.com>
2021-11-24 14:56:07 -05:00
Peter Holmberg
a5436b4435
Alerting: Move Alert Groups tab to end of tabs (#42241)
* move alertgroups tab to end of tabs

* more reorder
2021-11-24 18:28:19 +01:00
Jeremy Price
a145ec37bb
Handle request service account when not enabled (#42122)
* Handle request service account when not enabled
2021-11-24 11:56:55 +01:00
Gabriel MABILLE
eea0e6a6c0
AccessControl: Renamed orgs roles, removed fixed:orgs:reader introduced in beta1 (#42049)
* AccessControl: Rework Orgs roles

* Increase version for name migration

* Update pkg/api/roles.go

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>

* Use maintainer instead of manager

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2021-11-24 10:08:42 +01:00
idafurjes
87f148aa27
Chore: Add context to playlist (#41337)
* Add context to playlist

* Add AddEventListenerCtx and more context

* Update pkg/services/sqlstore/playlist.go

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>

* Update pkg/services/sqlstore/playlist.go

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>

* Update pkg/services/sqlstore/playlist.go

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>

* Fix lint

* Rename listener help function

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2021-11-19 14:32:14 +01:00
Ieva
03b7a55242
show admin nav link it the user only has permissions to view licensing and not other pages under admin node (#41948) 2021-11-19 11:02:13 +00:00
Gabriel MABILLE
0ee0a0b7a0
AccessControl: FGAC permissions for orgs endpoint on frontend (#41050)
* AccessControl: FGAC permissions for orgs endpoint on frontend

Protect org update endpoints

add or refactor missing right messages

cover org page

* removing scopes from orgs

* Perform permission control with global org

* Perform the error handling in case of 403

* Simplify frontend code by requiring read access for sure

* Remove roles I added to decrease the number of changes

* Remove the check for server admin to reduce the number of changes

* change error message

* Cleaning todos

* Remove unecessary changes

* Fix tests

* Update test snapshot

* Update pkg/api/roles.go

Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com>

* Update public/app/features/admin/AdminEditOrgPage.tsx

Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com>

* Format AdminEditOrgPage for linting

* Update public/app/features/admin/AdminEditOrgPage.tsx

Co-authored-by: Vardan Torosyan <vardants@gmail.com>

* Update public/app/features/admin/AdminEditOrgPage.tsx

Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>

* Update public/app/features/admin/AdminListOrgsPage.tsx

Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>

* Commit suggestions

* Commit suggestion canRead canWrite

* fix typo

Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com>
Co-authored-by: Vardan Torosyan <vardants@gmail.com>
Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>
2021-11-18 14:10:38 +01:00
Ieva
b7f47561b6
Access control: add roles to fixed groups (#41673)
* add roles to fixed groups

* add global to group name
2021-11-18 09:16:18 +00:00
Todd Treece
335e0cac11
Recorded Queries: Add frontend settings (#41841) 2021-11-17 22:45:05 +01:00
Karl Persson
d623285fcc
Access Control: Rename fixed roles (#41288)
* Rename fixed roles
* Update descriptions
* Update docs for fixed roles and permissions

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com>
2021-11-17 15:40:39 +01:00
Ursula Kallio
d76cea45b5
Found typo while reading code comments (#41740) 2021-11-17 15:19:45 +01:00
Selene
9f7942099b
Rendering: Add light theme for errors (#41616)
* Add light theme for error rendering

* Fix lint

* Update images and add rendering_limit_x images
2021-11-17 12:18:47 +01:00
Will Browne
2e3e7a7e55
Plugins: Plugin Store API returns DTO model (#41340)
* toying around

* fix refs

* remove unused fields

* go further

* add context

* ensure streaming handler is set
2021-11-17 12:04:22 +01:00
idafurjes
bb01f8c4cf
Chore: Add context dashboard version (#41672)
* Add context dashboard version

* Fix codeql
2021-11-17 10:57:37 +01:00
Gabriel MABILLE
818b8739c0
AccessControl: Remove scopes from orgs endpoints (#41709)
* AccessControl: Check permissions in target org

* Remove org scopes and add an authorizeInOrg middleware

* Use query result org id and perform users permission check globally for GetOrgByName

* Remove scope translation for orgs current

* Suggestion from Ieva
2021-11-17 10:12:28 +01:00
Tania B
b84496bc00
Fix decrypting in datasource update (#41704) 2021-11-16 16:47:59 +02:00
Katarina Yang
f49e08cb11
API: Fix dashboard quota limit for imports (#41495)
* API: Fix dashboard quota limit for imports

* fix: refactor TestDashboardQuota to check if dashboard saved

* Refactor: incorporate Sofia suggestions into tests

* refactor: add fields to TestDashboard struct

* write import test
2021-11-16 11:26:46 +02:00
Levente Balogh
4219e4f107
Plugins Catalog: hide plugins based on the Grafana config (#41679)
* refactor(pkg/api/frontendsettings): group plugin catalog settings

* feat(plugins/admin): add a default config value for `pluginCatalogHiddenPlugins`

* chore(grafana/config): add type for `pluginCatalogHiddenPlugins`

* feat(plugins/admin): hide plugins from the catalog based on the grafana config

* fix(plugins/admin): fix a rebase typo

* fix(plugins/admin): remove unnecessary filtering
2021-11-15 15:51:16 +01:00
Dimitris Sotirakis
2c8ac1f58f
Security Fix: Fine-grained access control enables organization admins to create/modify/delete user roles in other organization (#41694)
* 8.2.4: Fine-grained access control enables organization admins to create/modify/delete user roles in other organization

* Revert back calls with ScopeOrgID

Co-authored-by: gamab <gabi.mabs@gmail.com>
2021-11-15 15:35:09 +01:00
Marcus Efraimsson
b88d21a6cb
PluginsCatalog: Add backend support for hiding plugins in plugins catalog (#41563)
Add backend support for hiding plugins in plugins catalog. 

Ref #41074
2021-11-15 10:53:35 +01:00
Alexander Emelin
1700b2c2f3
live: add ws endpoint to push into pipeline (#41534) 2021-11-15 12:43:18 +03:00
idafurjes
d72e389d3d
Add context for GetAlertNotificationUidQuery (#41633) 2021-11-12 14:35:38 +01:00
Joan López de la Franca Beltran
44837fc592
Replace encryption.Service usages by secrets.Service (#41625)
* Replace encryption.Service by secrets.Service on expr.Service

* Replace encryption.Service by secrets.Service on live pkg

* Rename encryption.Service to encryption.Internal to clarify it must be not used
2021-11-12 12:16:39 +01:00
Jack Westbrook
3c3cf2eee9
Plugins Catalog: Install and show the latest compatible version of a plugin (#41003)
* fix(catalog): prefer rendering installed version over latest version

* feat(catalog): signify installed version in version history

* feat(catalog): introduce installedVersion and latestVersion

* refactor(catalog): use latestVersion for installation, simplify plugindetails header logic

* refactor(catalog): clean up installedVersion and latestVersion

* feat(catalog): use table-layout so versions list table has consistent column widths

* test(catalog): update failing tests

* removed the need of having a latest version in the plugin catalog type root level.

* fixed flaky test depending on what locale it was being running with.

* added missing test to verify version for a remote plugin.

* fixed version in header.

* preventing the UI from break if no versions are available.

* fixed failing test due to missing mock data.

* added todo as a reminder.

* refactor(catalog): prefer grafana plugin icons over gcom notfound images

* refactor(Plugins/Admin): change constant name

* refactor(Plugins/Admin): add comment to make condition easier to understand

* chore: update go modules

* feat(Backend/Plugins): add "dependencies" field to `PluginListItem`

* feat(Plugins/Admin): show the grafana dependency for the installed version

* refactor(Plugins/Admin): use the local version of links

* refactor(Plugins/Admin): prefer the local version for `.type`

* refactor(Plugins/ADmin): prefer the local `.description` field

* fix(Plugins/Admin): fix tests

* test(plugins/api): update the expected response for the `api/plugins` tests

* chore(Plugins/Admin): add todo comments to check preferation of remote/local values

* feat(backend/api): always send the grafana version as a header when proxying to GCOM

* feat(plugins/admin): use the `isCompatible` flag to get the latest compatible version

* feat(plugins/admin): show the latest compatible version in the versions list

* fix(plugins/admin): show the grafana dependency for the latest compatible version

* fix(plugins/admin): update the version list when installing/uninstalling a plugin

* test(plugins/admin): add some test-cases for the latest-compatible-version

* fix(plugins/admin): show the grafana dependency for the installed version (if installed)

* feat(plugins/backend): add the `dependencies.grafanaDependency` property to the plugin object

* test(plugins/backend): fix tests by adjusting expected response json

Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>
Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
2021-11-12 11:07:12 +01:00
Jeremy Price
69c5370e94
Accesscontrol: Add additional API keys to service account, move cloneserviceaccount to sqlstore (#41189)
* Add additional api key, move cloneserviceaccount

* Remove TODOs, for now

* Error messages

* Linter

* Security check

* Add comments

* Take service account id from correct variable

* Update user.go
2021-11-11 10:42:21 +00:00
Marcus Andersson
e5421dd53e
Chore: Change so we cache loading plugins by its version (#41367)
* making it possible to cache plugins based on the version.

* feat(plugincache): introduce function to invalidate entries

* removed todo's

* added tests for the cache buster.

* fixed tests.

* fixed failing tests.

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
2021-11-10 11:54:58 +01:00
Marcus Efraimsson
baab021fec
Chore: Refactor usage of legacy data contracts (#41218)
Refactor usage of legacy data contracts. Moves legacy data contracts 
to pkg/tsdb/legacydata package.
Refactor pkg/expr to be a proper service/dependency that can be provided 
to wire to remove some unneeded dependencies to SSE in ngalert and other places.
Refactor pkg/expr to not use the legacydata,RequestHandler and use 
backend.QueryDataHandler instead.
2021-11-10 11:52:16 +01:00
Alexander Emelin
e2ed140de2
Live: rename remote write backends to write configs (#41467) 2021-11-09 19:12:10 +03:00
Ryan McKinley
490d21fc5c
ds/query: use datasourceId if it exists in the request (#41446) 2021-11-09 07:11:09 -08:00
ying-jeanne
54de1078c8
remove the global log error/warn etc functions (#41404)
* remove the global log error/warn etc functions and use request context logger whenever possible
2021-11-08 17:56:56 +01:00
Katarina Yang
c4306f9b3e
Chore: add context to login (#41316)
* Chore: add context to login attempt file and tests

* Chore: add context

* Chore: add context to login and login tests

* Chore: continue adding context to login

* Chore: add context to login query
2021-11-08 15:53:51 +01:00
Ryan McKinley
3489721ed6
api/ds/query: simplify data sources lookup for queries and expressions (#41172) 2021-11-05 08:12:55 -07:00
Will Browne
8a42fca485
process app plugins first (#41346) 2021-11-05 15:07:53 +01:00
Will Browne
14742ea44a
add oauth pass thru logic to api/ds/query (#41352) 2021-11-05 15:07:04 +01:00
Agnès Toulet
3a6b8535b1
API: return resource ID when deleting datasource with UID and library element (#41342)
* API: return resource ID when deleting datasource and library element

* keep status codes consistent

* fix element ID

* add test

* improve response struct

* update endpoints documentation

* LibraryElementIDResponse -> DeleteLibraryElementResponse
2021-11-05 15:06:14 +01:00
Alexander Emelin
345f0b658d
Live: crud for remote write backends (#40147) 2021-11-05 12:13:40 +03:00
ying-jeanne
a404a311da
add context in the alert_notification (#41307) 2021-11-05 16:41:24 +08:00
Tania B
5652bde447
Encryption: Use secrets service (#40251)
* Use secrets service in pluginproxy

* Use secrets service in pluginxontext

* Use secrets service in pluginsettings

* Use secrets service in provisioning

* Use secrets service in authinfoservice

* Use secrets service in api

* Use secrets service in sqlstore

* Use secrets service in dashboardshapshots

* Use secrets service in tsdb

* Use secrets service in datasources

* Use secrets service in alerting

* Use secrets service in ngalert

* Break cyclic dependancy

* Refactor service

* Break cyclic dependancy

* Add FakeSecretsStore

* Setup Secrets Service in sqlstore

* Fix

* Continue secrets service refactoring

* Fix cyclic dependancy in sqlstore tests

* Fix secrets service references

* Fix linter errors

* Add fake secrets service for tests

* Refactor SetupTestSecretsService

* Update setting up secret service in tests

* Fix missing secrets service in multiorg_alertmanager_test

* Use fake db in tests and sort imports

* Use fake db in datasources tests

* Fix more tests

* Fix linter issues

* Attempt to fix plugin proxy tests

* Pass secrets service to getPluginProxiedRequest in pluginproxy tests

* Fix pluginproxy tests

* Revert using secrets service in alerting and provisioning

* Update decryptFn in alerting migration

* Rename defaultProvider to currentProvider

* Use fake secrets service in alert channels tests

* Refactor secrets service test helper

* Update setting up secrets service in tests

* Revert alerting changes in api

* Add comments

* Remove secrets service from background services

* Convert global encryption functions into vars

* Revert "Convert global encryption functions into vars"

This reverts commit 498eb19859.

* Add feature toggle for envelope encryption

* Rename toggle

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
Co-authored-by: Joan López de la Franca Beltran <joanjan14@gmail.com>
2021-11-04 18:47:21 +02:00
idafurjes
da5033f3fb
Chore: Add context to temp user (#41284)
* Add context to temp user

* Remove xorm and InTransaction
2021-11-04 11:17:07 +01:00
idafurjes
9340430723
Chore: Add alert ctx (#41161)
* Add context for alert

* Remove context.TODO

* Remove xorm

* Remove context.TODO

* Fix UsageStatsQuerier interface
2021-11-03 14:10:39 +01:00
Agnès Toulet
0997065e04
Navigation: remove redundant config nav link (#41252) 2021-11-03 14:07:58 +01:00
idafurjes
47f6bb3583
Chore: Add context to org (#40685)
* Add context to org

* Rebase

* Fix rebase
2021-11-03 11:31:56 +01:00
Santiago
6987ad7b4d
Fix issues with invalid Slack contact points (#41062)
* Add validation when creating/updating a contact point

* Change 201 status code for 200 (as it was before)
2021-11-02 10:11:19 -03:00
Marcus Efraimsson
f6be78b5ae
Chore: Propagate context for plugin settings (#41166)
Ref #36734
2021-11-02 13:42:55 +01:00
Marcus Efraimsson
1a89d97fed
Chore: Propagate context for preferences (#41167)
Ref #36734
2021-11-02 13:41:45 +01:00
Ashley Harrison
727a4bd9e4
Navigation: New NavBar designs behind feature toggle (#41045)
* Navigation: Remove plus button behind feature toggle

* Navigation: Add home button behind feature toggle

* Navigation: Move settings/admin to bottom section behind feature toggle

* Navigation: Refactor grafana logo to be a NavBarItem

* Navigation: Create new PluginSection and styling changes to support new sections

* Navigation: Hack to use mobile menu as a mega menu for now

* Navigation: Only render plugin section if there are items

* Navigation: mobile menu is always 100% width if toggle is off

* Navigation: Reset width back to 48 and fix broken css property

* Navigation: Create generic NavBarSection component to reduce repetition

* Navigation: Don't show sublinks for core items

* Navigation: Comments from UX review

* Navigation: Remove mobile menu hack

* Navigation: Unit tests for enrichConfigItems and other minor review comments

* Navigation: Move section logic to backend

* Navigation: Refactor alerting links out into a separate function

* Navigation: More tests for isLinkActive

* Linting...

* Navigation: Create new NavBar component for when feature toggle is enabled
2021-11-02 11:19:18 +00:00
Will Browne
b80fbe03f0
Plugins: Refactor Plugin Management (#40477)
* add core plugin flow

* add instrumentation

* move func

* remove cruft

* support external backend plugins

* refactor + clean up

* remove comments

* refactor loader

* simplify core plugin path arg

* cleanup loggers

* move signature validator to plugins package

* fix sig packaging

* cleanup plugin model

* remove unnecessary plugin field

* add start+stop for pm

* fix failures

* add decommissioned state

* export fields just to get things flowing

* fix comments

* set static routes

* make image loading idempotent

* merge with backend plugin manager

* re-use funcs

* reorder imports + remove unnecessary interface

* add some TODOs + remove unused func

* remove unused instrumentation func

* simplify client usage

* remove import alias

* re-use backendplugin.Plugin interface

* re order funcs

* improve var name

* fix log statements

* refactor data model

* add logic for dupe check during loading

* cleanup state setting

* refactor loader

* cleanup manager interface

* add rendering flow

* refactor loading + init

* add renderer support

* fix renderer plugin

* reformat imports

* track errors

* fix plugin signature inheritance

* name param in interface

* update func comment

* fix func arg name

* introduce class concept

* remove func

* fix external plugin check

* apply changes from pm-experiment

* fix core plugins

* fix imports

* rename interface

* comment API interface

* add support for testdata plugin

* enable alerting + use correct core plugin contracts

* slim manager API

* fix param name

* fix filter

* support static routes

* fix rendering

* tidy rendering

* get tests compiling

* fix install+uninstall

* start finder test

* add finder test coverage

* start loader tests

* add test for core plugins

* load core + bundled test

* add test for nested plugin loading

* add test files

* clean interface + fix registering some core plugins

* refactoring

* reformat and create sub packages

* simplify core plugin init

* fix ctx cancel scenario

* migrate initializer

* remove Init() funcs

* add test starter

* new logger

* flesh out initializer tests

* refactoring

* remove unused svc

* refactor rendering flow

* fixup loader tests

* add enabled helper func

* fix logger name

* fix data fetchers

* fix case where plugin dir doesn't exist

* improve coverage + move dupe checking to loader

* remove noisy debug logs

* register core plugins automagically

* add support for renderer in catalog

* make private func + fix req validation

* use interface

* re-add check for renderer in catalog

* tidy up from moving to auto reg core plugins

* core plugin registrar

* guards

* copy over core plugins for test infra

* all tests green

* renames

* propagate new interfaces

* kill old manager

* get compiling

* tidy up

* update naming

* refactor manager test + cleanup

* add more cases to finder test

* migrate validator to field

* more coverage

* refactor dupe checking

* add test for plugin class

* add coverage for initializer

* split out rendering

* move

* fixup tests

* fix uss test

* fix frontend settings

* fix grafanads test

* add check when checking sig errors

* fix enabled map

* fixup

* allow manual setup of CM

* rename to cloud-monitoring

* remove TODO

* add installer interface for testing

* loader interface returns

* tests passing

* refactor + add more coverage

* support 'stackdriver'

* fix frontend settings loading

* improve naming based on package name

* small tidy

* refactor test

* fix renderer start

* make cloud-monitoring plugin ID clearer

* add plugin update test

* add integration tests

* don't break all if sig can't be calculated

* add root URL check test

* add more signature verification tests

* update DTO name

* update enabled plugins comment

* update comments

* fix linter

* revert fe naming change

* fix errors endpoint

* reset error code field name

* re-order test to help verify

* assert -> require

* pm check

* add missing entry + re-order

* re-check

* dump icon log

* verify manager contents first

* reformat

* apply PR feedback

* apply style changes

* fix one vs all loading err

* improve log output

* only start when no signature error

* move log

* rework plugin update check

* fix test

* fix multi loading from cfg.PluginSettings

* improve log output #2

* add error abstraction to capture errors without registering a plugin

* add debug log

* add unsigned warning

* e2e test attempt

* fix logger

* set home path

* prevent panic

* alternate

* ugh.. fix home path

* return renderer even if not started

* make renderer plugin managed

* add fallback renderer icon, update renderer badge + prevent changes when renderer is installed

* fix icon loading

* rollback renderer changes

* use correct field

* remove unneccessary block

* remove newline

* remove unused func

* fix bundled plugins base + module fields

* remove unused field since refactor

* add authorizer abstraction

* loader only returns plugins expected to run

* fix multi log output
2021-11-01 10:53:33 +01:00
Marcus Efraimsson
2d2f7afbde
Chore: Propagate context for search (#41010)
Propagate context for search.Query, FindPersistedDashboardsQuery, 
GetUserStarsQuery. Followup on context.TODO added by #40810.

Ref #36734
2021-10-28 11:29:07 +02:00
Will Browne
67449b95e9
dispatch with context where missing (#40810) 2021-10-27 15:57:06 +02:00
Gabriel MABILLE
f6a9132975
AccessControl: Add FGAC to orgs endpoints (#39579)
* AccessControl: Add FGAC to orgs endpoints

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2021-10-27 13:13:59 +02:00
Gabriel MABILLE
a127e106db
AccessControl: Create FGAC roles for orgs (#40526)
* AccessControl: Create FGAC roles for orgs

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com>
2021-10-27 11:01:21 +02:00
ying-jeanne
681218275e
remove crit and trace (#40320) 2021-10-26 17:36:24 +02:00
Ryan McKinley
4680a8454f
Live: add rule for datasource (#40738) 2021-10-22 08:56:16 -07:00
Isabella Siu
97df4a57f4
GoogleCloudMonitoring: use grafana-google-sdk-go for auth (#40490) 2021-10-21 16:29:56 -04:00
Karl Persson
740444680c
Access Control: Add fgac to datasource query endpoints (#40294)
* Protect datasource tsdb and proxy endpoints with access control

* Add datasource query permissions to fixed admin role

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
Co-authored-by: Mitch Seaman <mjseaman@users.noreply.github.com>
2021-10-21 15:41:40 +02:00
Sofia Papagiannaki
2c28aea654
Hide Grafana 8 alerts for disabled org (#40687) 2021-10-21 11:04:41 +03:00
Jeremy Price
6dbb6408d4
Access Control: Add service accounts (#38994)
* Add extra fields to OSS types to support enterprise

* Create a service account at the same time as the API key

* Use service account credentials when accessing API with APIkey

* Add GetRole to service, merge RoleDTO and Role structs

This patch merges the identical OSS and Enterprise data structures, which improves the code for two reasons:

1.  Makes switching between OSS and Enterprise easier
2.  Reduces the chance of incompatibilities developing between the same functions in OSS and Enterprise

* If API key is not linked to a service account, continue login as usual

* Fallback to old auth if no service account linked to key

* Add CloneUserToServiceAccount

* Adding LinkAPIKeyToServiceAccount

* Handle api key link error

* Better error messages for OSS accesscontrol

* Set an invalid user id as default

* Re-arrange field names

* ServiceAccountId is integer

* Better error messages

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Eric Leijonmarck <eric.leijonmarck@gmail.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2021-10-20 14:36:11 +02:00
An
f4e78ea27b
Live: Test Converter tab (#40536) 2021-10-19 09:50:17 +02:00
Will Browne
e4297006f6
Chore: Propagate context for data source provisioning (#40235)
* context all the things

* apply feedback

* rollback some alerting changes

* rollback some alerting changes #2

* more rollbacks

* more rollbacks #2

* more rollbacks #3

* more rollbacks #4

* fix integration test

* add missing context

* add missing and remove incorrect dispatch
2021-10-18 17:06:19 +02:00
Guilherme Caulada
a9faab6b09
Dashboard: Add week start option to global and dashboard preferences (#40010)
* Add global week start option to shared preferences

* Add default_week_start to configuration docs

* Add week start option to dashboards

* Add week start argument to tsdb time range parser

* Fix strict check issues

* Add tests for week start

* Change wording on default_week_start documentation

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Update week_start column to be a nullable field

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>

* Update configuration to include browser option

* Update WeekStartPicker container selector

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>

* Add menuShouldPortal to WeekStartPicker to remove deprecation warning

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>

* Add inputId to WeekStartPicker

* Use e2e selector on WeekStartPicker aria-label

* Simplify WeekStartPicker onChange condition

* Specify value type on WeekStartPicker weekStarts

* Remove setWeekStart side effect from reducer

* Fix updateLocale failing to reset week start

* Store week start as string to handle empty values

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2021-10-18 10:27:14 -03:00
idafurjes
5a087d2708
Chore: Add context to team (#40504)
* Add ctx to team

* Remove convey from team
2021-10-18 14:02:39 +02:00
Ikko Ashimine
81e7cb60ff
Chore: Fix typo in dashboard.go (#39928)
requets -> requests
2021-10-15 10:33:01 +02:00
Peter Holmberg
75cff769f7
Alerting: Create alert from side menu (#40387)
* add entry for Create submeny

* extracting to function to resolve lint issue
2021-10-14 15:22:16 +02:00
Jesse Weaver
5af96544f3
Forbid creation of dashboard permissions with both a user and a team (#40104)
These permissions could be created through the API but would not show
correctly in the UI.
2021-10-13 12:16:58 -06:00
Emil Tullstedt
e73cd2fdeb
OAuth: Support PKCE (#39948) 2021-10-13 16:45:15 +02:00
Carl Bergquist
621bd477d0
Context: Add context to hasEditPermission call bus call (#40107)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
2021-10-11 14:36:57 +02:00
Carl Bergquist
f20de5588b
add context to api crud calls (#40047)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
2021-10-11 14:35:31 +02:00
Carl Bergquist
c9f25cf0a5
Context: Add context to /api/health calls (#40031)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
2021-10-11 14:35:03 +02:00
Serge Zaitsev
57fcfd578d
Chore: replace macaron with web package (#40136)
* replace macaron with web package

* add web.go
2021-10-11 14:30:59 +02:00
idafurjes
e822c8a24d
CloudMonitoring: Migrate to use backend plugin SDK contracts (#38650)
* Use SDK contracts for cloudmonitoring

* Get build running, tests passing and do some refactoring (#38754)

* fix build+tests and refactor

* remove alerting stuff

* remove unused field

* fix plugin fetch

* end to end

* resp rename

* tidy annotations

* reformatting

* update refID

* reformat imports

* fix styling

* clean up unmarshalling

* uncomment + fix tests

* appease linter

* remove spaces

* remove old cruft

* add check for empty queries

* update tests

* remove pm as dep

* adjust proxy route contract

* fix service loading

* use UNIX val

* fix endpoint + resp

* h@ckz for frontend

* fix resp

* fix interval

* always set custom meta

* remove unused param

* fix labels fetch

* fix linter

* fix test + remove unused field

* apply pr feedback

* fix grafana-auto intervals

* fix tests

* resolve conflicts

* fix bad merge

* fix conflicts

* remove bad logger import

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
Co-authored-by: Will Browne <will.browne@grafana.com>
2021-10-08 14:46:35 +02:00
Joan López de la Franca Beltran
722c414fef
Encryption: Refactor securejsondata.SecureJsonData to stop relying on global functions (#38865)
* Encryption: Add support to encrypt/decrypt sjd

* Add datasources.Service as a proxy to datasources db operations

* Encrypt ds.SecureJsonData before calling SQLStore

* Move ds cache code into ds service

* Fix tlsmanager tests

* Fix pluginproxy tests

* Remove some securejsondata.GetEncryptedJsonData usages

* Add pluginsettings.Service as a proxy for plugin settings db operations

* Add AlertNotificationService as a proxy for alert notification db operations

* Remove some securejsondata.GetEncryptedJsonData usages

* Remove more securejsondata.GetEncryptedJsonData usages

* Fix lint errors

* Minor fixes

* Remove encryption global functions usages from ngalert

* Fix lint errors

* Minor fixes

* Minor fixes

* Remove securejsondata.DecryptedValue usage

* Refactor the refactor

* Remove securejsondata.DecryptedValue usage

* Move securejsondata to migrations package

* Move securejsondata to migrations package

* Minor fix

* Fix integration test

* Fix integration tests

* Undo undesired changes

* Fix tests

* Add context.Context into encryption methods

* Fix tests

* Fix tests

* Fix tests

* Trigger CI

* Fix test

* Add names to params of encryption service interface

* Remove bus from CacheServiceImpl

* Add logging

* Add keys to logger

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>

* Add missing key to logger

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>

* Undo changes in markdown files

* Fix formatting

* Add context to secrets service

* Rename decryptSecureJsonData to decryptSecureJsonDataFn

* Name args in GetDecryptedValueFn

* Add template back to NewAlertmanagerNotifier

* Copy GetDecryptedValueFn to ngalert

* Add logging to pluginsettings

* Fix pluginsettings test

Co-authored-by: Tania B <yalyna.ts@gmail.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2021-10-07 17:33:50 +03:00
Selene
da813877fb
Create search filters by interface (#39843)
* Extract search users to a new service

* Fix wire provider

* Fix common_test and remove RouteRegister

* Remove old endpoints

* Fix test

* Create search filters using interfaces

* Move Enterprise filter, rename filter for filters and allow use filters with params

* Each filter has unique key

* Back activeLast30Days filter to OSS

* Fix tests

* Delete unusued param

* Move filters to searchusers service and small refactor

* Fix tests
2021-10-07 16:06:16 +02:00
Karl Persson
efbb4c890f
Access Control: Add scope type prefix (#40076)
* prefix runtime scopes with key type
2021-10-07 11:54:43 +02:00
Ashley Harrison
009a26264c
NavBar: Order App plugins alphabetically (#40078)
* NavBar: Order App plugins alphabetically

* Update pkg/api/index.go

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
2021-10-07 10:08:47 +01:00
Gabriel MABILLE
458371c8eb
AccessControl: Extend scope parameters with extra params from context (#39722)
* AccessControl: Extend scope parameters with extra params from context

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2021-10-06 13:15:09 +02:00
Serge Zaitsev
3131388084
Chore: Imperative request data binding (#39837)
* rename Bind to BindMiddleware

* make things private

* removed unused part of data bindings

* provide json and form binding helpers

* add example of binding migration in login api

* implement validation

* fix tests

* remove debug output

* put new bind api into macaron pacakge

* revert bind api breaking change
2021-10-06 12:52:27 +02:00
Marcus Efraimsson
329f96db1a
Fix static path matching issue in macaron (#40023)
Co-authored-by: Malcolm Holmes <mdh@odoko.co.uk>
2021-10-05 19:38:09 +02:00
Ieva
52220b2470
AccessControl: frontend changes for adding FGAC to licensing (#39484)
* refactor licenseURL function to use context and export permission evaluation fction

* remove provisioning file

* refactor licenseURL to take in a bool to avoid circular dependencies

* remove function for appending nav link, as it was only used once and move the function to create admin node

* better argument names

* create a function for permission checking

* extend permission checking when displaying server stats

* enable the use of enterprise access control actions when evaluating permissions

* import ordering

* move licensing FGAC action definitions to models package to allow access from oss

* move evaluatePermissions for routes to context serve

* change permission evaluator to take in more permissions

* move licensing FGAC actions again to appease wire

* avoid index out of bounds issue in case no children are passed in when creating server admin node

* simplify syntax for permission checking

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>

* update loading state for server stats

* linting

* more linting

* fix test

* fix a frontend test

* update "licensing.reports:read" action naming

* UI doesn't allow reading only licensing reports and not the rest of licensing info

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2021-10-05 14:54:26 +01:00
idafurjes
2759b16ef5
Chore: Add context for dashboards (#39844)
* Add context for dashboards

* Remove GetDashboardCtx

* Remove ctx.TODO
2021-10-05 13:26:24 +02:00
Gabriel MABILLE
4160429b71
AccessControl: rename data source id read action (#39966) 2021-10-05 09:39:00 +02:00
idafurjes
f4f0d74838
Chore: Add context to user (#39649)
* Add context to user

* Add context for enterprise

* Add context for UpdateUserLastSeenAtCommand

* Remove xorm
2021-10-04 15:46:09 +02:00
Guilherme Caulada
706a665240
Auth: add name parameter to auth.saml (#39883)
* add name parameter to auth.saml

* Create constant to store default SAML name
2021-10-04 09:58:16 -03:00
Alexander Emelin
29f3e175b6
Live: test pipeline convert endpoint (#39480) 2021-09-30 19:28:06 +02:00
Alexander Emelin
a696fc8b2b
Live: pipeline rule crud (file-based, still for MVP) (#39238) 2021-09-30 19:29:32 +03:00
Sofia Papagiannaki
012d4f0905
Alerting: Remove ngalert feature toggle and introduce two new settings for enabling Grafana 8 alerts and disabling them for specific organisations (#38746)
* Remove `ngalert` feature toggle

* Update frontend

Remove all references of ngalert feature toggle

* Update docs

* Disable unified alerting for specific orgs

* Add backend tests

* Apply suggestions from code review

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Disabled unified alerting by default

* Ensure backward compatibility with old ngalert feature toggle

* Apply suggestions from code review

Co-authored-by: gotjosh <josue@grafana.com>
2021-09-29 16:16:40 +02:00
Selene
02702eb82d
Extract search users functions into a service (#39002)
* Extract search users to a new service

* Fix wire provider

* Fix common_test and remove RouteRegister

* Remove old endpoints

* Fix test

* Add indexes to dashboards and orgs tables

* Fix lint
2021-09-29 12:51:49 +02:00
Tania B
990911a3b9
Chore: Cleanup usageStatsMock duplication (#39710)
* Chore: Cleanup usageStatsMock duplication

* Remove making a new slice for UsageStatsMock
2021-09-29 09:59:02 +03:00
idafurjes
b255c1b992
Chore: Add context to star and stats (#39591)
* Add context to star and stats

* Use WithTransactionalDbSession

* Add additional ctx

* Remove convey

* Fix star handler name

* Use WithDbSession, use DispatchCtx

* Remove xorm from star
2021-09-28 17:54:45 +02:00
idafurjes
65ebb04cf3
Chore: Add context to org users (#39526)
* Add context to org users

* Fix go lint

* Roll back xorm refactor

* Use WithTransactionalDbSession

* Update sqlstore.go

Fix typo

* Update org_users.go

Fix typo
2021-09-27 16:43:16 +02:00
Agnès Toulet
57b20335e6
LibraryPanels: Refactor to use context.Context instead of models.ReqContext (#39561) 2021-09-27 09:04:36 +02:00
Marcus Efraimsson
518a0d0458
Chore: Propagate context for dashboard guardian (#39201)
Require guardian.New to take context.Context as first argument. 
Migrates the GetDashboardAclInfoListQuery to be dispatched using context.

Ref #36734

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
Co-authored-by: sam boyer <sam.boyer@grafana.com>
2021-09-23 17:43:32 +02:00
Tania B
b9acdce837
Chore: Fix grafana live stats reset when sending usage stats (#39558) 2021-09-23 12:55:00 +03:00
Joan López de la Franca Beltran
c75737c808
Usage Stats: Decouple from GrafanaLive (#39512)
* Usage Stats: Decouple from GrafanaLive
2021-09-22 16:28:40 +02:00
Gabriel MABILLE
1d56c32ab0
AccessControl: Protect /datasources endpoints consistently with NavLinks permissions (#39319) 2021-09-22 13:50:21 +02:00
Alexander Emelin
0bf70b14fd
Live: api to show available pipeline entities (#39469)
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2021-09-21 11:57:58 -07:00
Joan López de la Franca Beltran
a680162792
Usage Stats: Split domain & service packages (#39488) 2021-09-21 20:50:37 +02:00
Marcus Efraimsson
1e4a660ea7
Chore: Propagate context for quotas (#39205)
Propagate context for quotas and queries/commands.

Ref #36734
2021-09-20 17:05:30 +02:00
Hugo Häggmark
2696be49b9
LibraryPanels: Improves export and import of library panels between orgs (#39214)
* Chore: adds tests to reducer

* Refactor: rewrite state

* Refactor: adds library panels to export

* wip

* Refactor: adds import library panels

* Refactor: changes UI

* Chore: pushing drone

* Update public/app/features/manage-dashboards/components/ImportDashboardForm.tsx

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Update public/app/features/manage-dashboards/components/ImportDashboardForm.tsx

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Chore: reverted unknown merge changes

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
2021-09-20 10:58:24 +02:00
Gabriel MABILLE
4be9ec8f72
AccessControl: Protect org users lookup (#38981)
* Move legacy accesscontrol to middleware layer

* Remove bus usage for this endpoint

* Add tests for legacy accesscontrol

* Fix tests for org user and remove one more bus usage

* Added test for FolderAdmin as suggested in the review
2021-09-17 09:19:36 +02:00
Alexander Emelin
87cdda4106
Live: return pipeline menu, now with feature toggle (#39280) 2021-09-16 08:34:12 -07:00
Torkel Ödegaard
95fd659bfc
SideMenu: Remove live section from main side menu (#39278) 2021-09-16 10:12:54 +02:00
Erik Sundell
9d3f4f5983
Analytics: Instrument Azure Application Insights (#38553)
* add backend

* read config and pass to backend

* update config docs

* change var name

* use connection string instead of instrumentation key

* add config for endpoint url. update docs

* update default ini

* add spaces

* remove space

* Update docs/sources/administration/configuration.md

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Update conf/defaults.ini

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* Update conf/defaults.ini

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
2021-09-15 13:00:38 +02:00
Serge Zaitsev
6005e6572d
Chore: fix param names in ctx.ParamsInt64 (#39223) 2021-09-15 12:14:15 +02:00
Serge Zaitsev
063160aae2
Chore: pass url parameters through context.Context (#38826)
* pass url parameters through context.Context

* fix url param names without colon prefix

* change context params to vars

* replace url vars in tests using new api

* rename vars to params

* add some comments

* rename seturlvars to seturlparams
2021-09-14 18:34:56 +02:00
Marcus Efraimsson
fa9857499b
Chore: GetDashboardQuery should be dispatched using DispatchCtx (#36877)
* Chore: GetDashboardQuery should be dispatched using DispatchCtx

* Fix after merge

* Changes after review

* Various fixes

* Use GetDashboardCtx function instead of GetDashboard
2021-09-14 16:08:04 +02:00
An
45e67630e8
Live: admin config UI (#39103)
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
Co-authored-by: Atif Ali <atifshoukatali@yahoo.com>
2021-09-13 21:09:55 -07:00
Serge Zaitsev
abfdfcf405
Plugins: Support multiple HTTP methods in plugin.json routes (#39069)
* Fix: support comma-separated methods in plugin.json

* update docs about multiple methods per route
2021-09-13 13:32:11 +02:00
Ryan McKinley
6bda64cb19
Grafana: include a built-in backend datasource (#38571) 2021-09-10 07:44:47 -07:00
Alexander Emelin
3ee861f57e
Live: declarative processing pipeline, input -> frames -> output, toggle protected POC (#37644) 2021-09-09 19:19:29 +03:00
Gabriel MABILLE
8585273c29
AccessControl: Restrict more the access to the data sources configuration tab (#38966)
Co-authored-by: Emil Tullstedt <sakjur@users.noreply.github.com>
2021-09-08 13:15:21 +02:00
Will Browne
40643ee023
track signature files + add warn log (#38938) 2021-09-08 08:49:05 +02:00
Ryan McKinley
9aa03acfa6
Chore: remove sql testdata (#38945) 2021-09-07 16:35:52 -07:00
Gabriel MABILLE
a811d7d76f
Access control: Add a scope to Data Sources GET endpoint (#38933) 2021-09-07 17:13:11 +02:00
Gabriel MABILLE
9f29241a0c
AccessControl: add one-dimensional permissions to datasources (#38070)
* AccessControl: add one-dimensional permissions to datasources in the backend

* AccessControl: add one-dimensional permissions to datasources in the frontend (#38080)

Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
2021-09-01 15:18:17 +02:00
Joan López de la Franca Beltran
6cfb640a0b
Chore: Refactor securedata to remove global encryption calls from dashboard snapshots (#38714)
* Add encryption service

* Add tests for encryption service

* Inject encryption service into http server

* Replace encryption global function usage in login tests

* Migrate to Wire

* Move Encryption bindings to OSS Wire set

* Chore: Refactor securedata to remove global encryption calls from dashboard snapshots

* Fix dashboard snapshot tests

* Remove no longer user test

* Add dashboard snapshots service tests

* Refactor service initialization

* Set up dashboard snapshots service as a background service

Co-authored-by: Tania B <yalyna.ts@gmail.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2021-09-01 13:05:15 +02:00
Serge Zaitsev
c3ab2fdeb7
Macaron: remove custom Request type (#37874)
* remove macaron.Request, use http.Request instead

* remove com dependency from bindings module

* fix another c.Req.Request
2021-09-01 11:18:30 +02:00
Tania B
bfde29d107
Chore: Remove global encryption calls from authinfoservice (#38591)
* Add encryption service

* Add tests for encryption service

* Inject encryption service into http server

* Replace encryption global function usage in login tests

* Migrate to Wire

* Refactor authinfoservice to use encryption service

Co-authored-by: Joan López de la Franca Beltran <joanjan14@gmail.com>
Co-authored-by: Joan López de la Franca Beltran <5459617+joanlopez@users.noreply.github.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2021-08-31 14:00:13 +02:00
Ashley Harrison
7a242afcd6
Sidemenu: Refactor BottomNavLinks to use SideMenuDropDown (#38598)
* Sidemenu: Attempt to refactor BottomNavLinks to use SideMenuDropDown

* BottomNavLinks: Rewrite existing enzyme tests in RTL

* BottomNavLinks: Use object spreading instead of slicing
2021-08-31 10:37:51 +01:00
Selene
e47a60f511
Add filter to search users by active (#38637)
* Add filter to search users by active

* Fix query
2021-08-31 11:35:16 +02:00
Tania B
a0108a1e5b
Encryption: Extract encryption into service (#38442)
* Add encryption service

* Add tests for encryption service

* Inject encryption service into http server

* Replace encryption global function usage in login tests

* Apply suggestions from code review

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>

* Migrate to Wire

* Undo non-desired changes

* Move Encryption bindings to OSS Wire set

Co-authored-by: Joan López de la Franca Beltran <joanjan14@gmail.com>
Co-authored-by: Joan López de la Franca Beltran <5459617+joanlopez@users.noreply.github.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2021-08-30 19:39:55 +02:00
Serge Zaitsev
d15cbe4b4e
Macaron cleanup (#37795)
* simplify some dependency injection in macaron
* remove unused internal server error handler from macaron
* remove internal server error handler from the router
* remove unused combo router api
* remove unused parts of the macaron router
2021-08-30 11:48:34 +02:00
idafurjes
7faea40674
API: Add short url validation (#38436)
* Add short url validation
Path should not contain string ../

* Update pkg/api/short_url.go

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2021-08-26 09:07:27 +02:00
Arve Knudsen
78596a6756
Migrate to Wire for dependency injection (#32289)
Fixes #30144

Co-authored-by: dsotirakis <sotirakis.dim@gmail.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Ida Furjesova <ida.furjesova@grafana.com>
Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com>
Co-authored-by: spinillos <selenepinillos@gmail.com>
Co-authored-by: Karl Persson <kalle.persson@grafana.com>
Co-authored-by: Leonard Gram <leo@xlson.com>
2021-08-25 15:11:22 +02:00
Gabriel MABILLE
f9273d0d37
AccessControl: Add a mock (#38515) 2021-08-24 20:12:48 +02:00
gotjosh
14a0519338
Alerting: Remove Multiorg alertmangaer from the top-level services (#38506)
Removes the registration of the multi-org alertmanager, it is started as a subservice of ngalerting.
2021-08-24 19:11:28 +02:00
Alex Khomenko
6e639f3c72
Admin: Update stats page UI (#38014)
* Add StatCard

* Style cards

* Update types

* Add tests

* Move stats tab into licencing

* Prevent UI jumps when loading stats

* Fix merge conflicts

* Revert docs format
2021-08-24 19:13:48 +03:00
David Parrott
7fbeefc090
Alerting: create wrapper for Alertmanager to enable org level isolation (#37320)
Introduces org-level isolation for the Alertmanager and its components.

Silences, Alerts and Contact points are not separated by org and are not shared between them.

Co-authored with @davidmparrott and @papagian
2021-08-24 11:28:09 +01:00