Commit Graph

3712 Commits

Author SHA1 Message Date
Gabriel MABILLE
2cc276567d
AccessControl: Hide basic roles (#48549)
Co-authored-by: Jguer <joao.guerreiro@grafana.com>

Co-authored-by: Jguer <joao.guerreiro@grafana.com>
2022-04-29 17:35:41 +02:00
Karl Persson
6c6137f45a
Access control: Pass access control metadata for api keys (#48445)
* Move ApiKeyDTO to dtos package

* Add access control filter to api keys

* pass user in GetApiKeysQuery

* Add api key metadata to DTO

* Remove scope all requirement from get api keys endpoint

* Handle api key access control metadata in frondend
2022-04-29 15:30:24 +02:00
ying-jeanne
1667a7c0da
Chore: Modify patch and update of preference to take homedashboarduid than h… (#48281)
* modify patch and update of preference to take homedashboarduid than homedashboardid

* to be tested

* use getdashboard

* update doc
2022-04-29 14:37:33 +02:00
Jean-Philippe Quéméner
9e3a01a1be
Alerting: skip flaky test (#48500) 2022-04-29 12:32:30 +02:00
Shirley
7bb4f5cd9b
CloudWatch: Add dynamic labels feature toggle (#48498) 2022-04-29 11:43:04 +02:00
Karl Persson
c207ea30eb
Access Control: Remove unused option (#48317)
* Remove unused option
2022-04-29 11:05:51 +02:00
Ivana Huckova
b92fe0e0f5
Query history: Add from and to parameters (#48212)
* Query history: Add from and to parameters

* Update docs/sources/http_api/query_history.md

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

* Update docs/sources/http_api/query_history.md

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

* Update docs/sources/http_api/query_history.md

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

* Implement Grafana relative time range

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
2022-04-29 09:55:33 +02:00
Sofia Papagiannaki
3e752a0db1
Alerting: modify alertmanager endpoints for proxying using the datasource UID (#47978)
* Alerting: enable proxying alertmanager calls using the datasource UID

* Remove use of datasource ID from the API

* Update frontend
2022-04-29 10:25:22 +03:00
Jean-Philippe Quéméner
9e21e4d1c1
Alerting: indicate whether an alertrule is provisioned (#48458) 2022-04-28 21:27:34 +02:00
Santiago
d9de621d20
Fix Discord notifications not being sent due to templating issues (#48208)
* empty URLs fixed

* move comment

* test cases
2022-04-28 15:58:07 -03:00
Alexander Weaver
735822e48a
Alerting: Add provisioning GET routes for message templates (#48367)
* Template service

* Add GET routes and implement them

* Generate mock for persist layer

* Unit tests for reading templates

* Set up composition root and get integration tests working

* Fix prealloc issue

* Extract setup boilerplate

* Update AuthorizationTest

* Rebase and resolve

* Fix linter error
2022-04-28 13:51:57 -05:00
Artur Wierzbicki
d4616cfe26
Search: support auth filter based on access control/rbac (#48350)
* #45498: add rbac support in searchv2

* to revert: fix dependency cycle

* Revert "to revert: fix dependency cycle"

This reverts commit 1ffbee73ec.

* added a TODO for caching user permissions

* add orgId to `getDashboardReadFilter`

* use orgId from signedInUser

* goimport
2022-04-28 22:16:23 +04:00
Alexander Emelin
4551f05994
Search: fix missing dashboards due to empty uid, log errors (#48361) 2022-04-28 19:29:09 +03:00
gotjosh
d451d02628
Alerting Changelog: Cut & Fix (#48402) 2022-04-28 11:20:35 +01:00
Artur Wierzbicki
736be74128
Chore: Add Usage stats providers registry (#48357)
* add usage stats providers

* migrate thumbnails service to `registry.ProvidesUsageStats`

* snake -> camel

* lint fix

* migrate accesscontrol to `registry.ProvidesUsageStats`

* add accesscontrol to usage stats providers registry

* fix test

* added a note about errors
2022-04-28 13:06:49 +04:00
Karl Persson
e9a93ebfc9
Access Control: Move access control middlewares to domain package (#48322)
* Move access control middleware to domain package
2022-04-28 10:46:18 +02:00
Alexander Weaver
60ec10566f
Extract Route validation from serialization methods so it can be re-used (#47649)
* Extract validation and reject invalid policies

* Validation in dedicated file

* Tests for validation

* Extract root route validation

* Update call and drop TODO

* empty commit to kick actions

* Normalization should be idempotent

* Cleaner representation of validation errors, chain errors properly

* Make internal validate unexported

* Fix missed rename

* Genericize error message

* Improve method names

* Rebase, fix

* Update asserts
2022-04-27 15:15:41 -05:00
An
900d9bf9a1
FileStorage: Add upload form (#46749)
* move upload to http

* use storage from grafanads

* rever gomod changes

* fix test

* wip

* add upload func

* update upload func

* writing to uploads

* edit response from service

* use dropzone for UI

* modify response struct in service

* better read file

* set content type for svg

* restrict file types upload

* add test and clean up errors

* pass test

* fix backend lint errors

* limit type of files on FE

* add TODO for after merge

* rebase with storage changes

* comment out unused function

* update UI to not have 2 uploads

* only call upload on select

* use utils function to find * in path

* show preview on drag over

* not allowing upload of svg

* add preview to upload tab

* no console.log

* resolve conflicts

* refactor log line

* fix failing BE test

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
Co-authored-by: Artur Wierzbicki <artur.wierzbicki@grafana.com>
2022-04-27 15:12:48 -04:00
Yuriy Tseretyan
4b417c8f3e
use NaN if condition value is nil (#48370) 2022-04-27 15:59:13 -03:00
Jean-Philippe Quéméner
a3256bafa7
Alerting: indicate whether contact point is provisioned (#48323) 2022-04-27 20:53:36 +02:00
cianooooo
e8f4b58a8b
Alerting: Add additional customisation to ngalert MS Teams notifier (#46372)
Makes the Title and Section Title of the Teams message customisable.
Closes #46366
2022-04-27 13:03:15 -04:00
Artur Wierzbicki
25e153e4e7
Search: in-memory index (#47709)
* #45498: add entity events table

* #45498: add entity events service

* #45498: hook up entity events service to http server

* #45498: use `dashboards.id` rather than `uid` and `org_id` in grn

* Update pkg/services/entityevents/service.go

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>

* #45498: move entityeventsservice to services/store

* #45498: add null check

* #45498: rename

* #45498: fix comment

* #45498: switch grn back to uid

* Search: listen for updates (#47719)

* #45498: wire entity event service with searchv2

* load last event id before building index for org 1

* fix service init in integration tests

* depend on required subset of event store methods

* Update pkg/services/sqlstore/migrations/entity_events_mig.go

Co-authored-by: Alexander Emelin <frvzmb@gmail.com>

* #45498: pointer receiver

* #45498: mockery!

* #45498: add entity events service to background services

* dashboard query pagination, allow queries while re-indexing

* log level cleanups, use rlock, add comments

* fix lint, check feature toggle in search v2 service

* use unix time for event created column

* add missing changes for created column

* fix integration tests init

* log re-index execution times on info level

* #45498: fix entityEventsService tests

* #45498: save events on dashboard delete

* use camel case for log labels

* formatting

* #45498: rename grn to entityid

* #45498: add `IsDisabled` to entityEventsService

* #45498: remove feature flag from migration

* better context usage, fix capacity, comments/cleanups

* replace print with logger

* Revert "#45498: remove feature flag from migration"

This reverts commit ed23968898.

* revert:revert:revert conditional feature flag

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
Co-authored-by: Alexander Emelin <frvzmb@gmail.com>
2022-04-27 12:29:39 +04:00
Joe Blubaugh
103087a1a5
Unified Alerting: Validate PostableSilence API. (#46892)
Invalid PostableSilences could be passed to the Alerting API - if they
are passed all the way down into the alertmanager data layer, they can
cause a panic. This change adds validation to avoid a panic in the
alertmanager.
2022-04-27 15:55:47 +08:00
Alexander Weaver
078a578803
Drop ProvenanceOrgAdapter and build into store API instead (#48137) 2022-04-26 10:30:57 -05:00
Matthew Jacobson
0301d956da
Alerting: Create fewer contact points on migration (#47291)
* Alerting: Create fewer contact points on migration

Previously a new contact point was created for every unique combination
of channels attached to any legacy alert. This was very hard to maintain,
requiring modifications in every generated contact point.

This change deduplicates the generated contact points to a more
reasonable state. There should now only be one contact point per legacy
channel, and we attached multiple contact points to a route by nesting
them. The sole exception to this is if there were multiple default
legacy channels, in which case we create a redundant contact point
containing all of them used only in the root policy. This allows for a
much simpler notification policy structure.

Co-authored-by: gotjosh <josue.abreu@gmail.com>
2022-04-26 16:17:30 +02:00
kay delaney
3b4d237ade
Notifications: Hide display of trace ID behind feature flag (#48057)
* Notifications: Hide display of trace ID behind feature flag
2022-04-26 14:31:27 +01:00
Ashley Harrison
e420252d45
move saved items feature behind separate feature toggle (#48117) 2022-04-26 11:27:01 +01:00
Emil Tullstedt
fc0346fe5b
Dashboards: Use home dashboard from org again (#48244)
* Dashboards: Use home dashboard from org again

* Set homeDashboardID

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2022-04-26 11:46:26 +02:00
Ryan McKinley
e0aeb83786
Export: introduce export plumbing (behind dev feature flag) (#48091) 2022-04-25 16:59:18 -07:00
Guilherme Caulada
53e9bf47db
Secrets: Implement tests and debug log improvements on unified secrets (#48213)
* Add test for decrypted values on datasource service

* Add debug log when fail to parse secure json fields

* Fix minor import issue

* Refactor encJson to json and simplejson to sjson on tests
2022-04-25 15:12:44 -03:00
Kat Yang
098563179b
Chore: Remove final x from sqlstore (#48086)
* Chore: Remove final x from everywhere

* Fix errors

* Fix: fix lint and nil pointer err

* Remove x from the sqlstore 🎉
2022-04-25 13:07:11 -04:00
Guilherme Caulada
a367ad730c
Secrets: Implement basic unified secret store service (#45804)
* wip: Implement kvstore for secrets

* wip: Refactor kvstore for secrets

* wip: Add format key function to secrets kvstore sql

* wip: Add migration for secrets kvstore

* Remove unused Key field from secrets kvstore

* Remove secret values from debug logs

* Integrate unified secrets with datasources

* Fix minor issues and tests for kvstore

* Create test service helper for secret store

* Remove encryption tests from datasources

* Move secret operations after datasources

* Fix datasource proxy tests

* Fix legacy data tests

* Add Name to all delete data source commands

* Implement decryption cache on sql secret store

* Fix minor issue with cache and tests

* Use secret type on secret store datasource operations

* Add comments to make create and update clear

* Rename itemFound variable to isFound

* Improve secret deletion and cache management

* Add base64 encoding to sql secret store

* Move secret retrieval to decrypted values function

* Refactor decrypt secure json data functions

* Fix expr tests

* Fix datasource tests

* Fix plugin proxy tests

* Fix query tests

* Fix metrics api tests

* Remove unused fake secrets service from query tests

* Add rename function to secret store

* Add check for error renaming secret

* Remove bus from tests to fix merge conflicts

* Add background secrets migration to datasources

* Get datasource secure json fields from secrets

* Move migration to secret store

* Revert "Move migration to secret store"

This reverts commit 7c3f872072.

* Add secret service to datasource service on tests

* Fix datasource tests

* Remove merge conflict on wire

* Add ctx to data source http transport on prometheus stats collector

* Add ctx to data source http transport on stats collector test
2022-04-25 13:57:45 -03:00
gotjosh
25c07ff85e
Alerting: Wrap legacy alerting metrics with legacy_ (#48190)
* Alerting: Wrap legacy alerting metrics with `legacy_`
2022-04-25 17:19:36 +02:00
George Robinson
c5547123bc
Remove redundant queries in GetAlertRules and GetOrgAlertRules and replace with ListAlertRules (#48108) 2022-04-25 11:42:42 +01:00
Ieva
68ca5b2e05
Access control: refactor RBAC checks (#48107)
* refactor RBAC checks

* fix a test

* another test fix

* and another
2022-04-25 10:42:09 +02:00
Artur Wierzbicki
2e599643f6
Previews: refactor (#47728)
* #44449: return standard thumb service even if auth setup fails

* #44449: remove dashboardPreviewsScheduler feature flag

* #44449: externalize dashboardPreviews config

* #44449: disable previews by default

* #44449: rename logger

* #44449: dashboardPreviewsAdmin feature requires dev mode

* #44449: retrigger CII
2022-04-25 01:55:10 +04:00
Torkel Ödegaard
70a7b73839
Preferences: Fixes broken preferences after recent merge (#48157)
* Preferences: Fixes broken preferences after recent merge

* Added check

* Shorter syntax

* Fixed test

* Remove error, and remove duplicate call
2022-04-24 17:50:10 +02:00
Yuriy Tseretyan
75ba4e98c6
Alerting: Remove unused features from ticker + metric + tests (#47828)
* remove not used code:
  - remove offset in ticket because it is not used
  - remove unused ticker and scheduler methods

* use duration for interval
* add metrics grafana_alerting_ticker_last_consumed_tick_timestamp_seconds, grafana_alerting_ticker_next_tick_timestamp_seconds, grafana_alerting_ticker_interval_seconds
2022-04-22 15:09:47 -04:00
Alexander Weaver
8310789ef1
Indicate whether routes are provisioned when GETting Alertmanager configuration (#47857)
* Test composition simplification from last PR

* Policies use proper API model everywhere

* Expose policy provenance in API, miss some dep injection

* Complete injection

* fix args

* Tests for provenance value

* Extract test helpers so tests are very readable

* Single source adapter struct that was copied in 3 places

* Drop redundant test

* Resolve merge conflicts on changelog
2022-04-22 11:57:56 -05:00
Gabriel MABILLE
94fd03f44f
LDAP: Fix debug view to display the actual computed mapping in ldap.go (#48103)
* LDAP debug fix with Org role inheritance

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

* ldap debug coherent with ldap.go

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

Co-authored-by: Jguer <joao.guerreiro@grafana.com>
2022-04-22 15:45:54 +02:00
Artur Wierzbicki
87dc1bfc88
Chore: enforce feature naming convention (#48053)
* enforce feature naming convention

* fix link

* add comment

* fix lint

* move the feature name check test to toggles_gen_test
2022-04-22 08:23:30 +04:00
Kristina
3e7db088ac
Command Palette Scaffolding + Explore (#47445)
* Add feature flag and scaffodling

* start adding actions

* WIP

* move action files

* Start adding styles

* Fix implementation based on feedback

* Add more hackathon code back to command palette

* Cleanup

* Cleanup unused service files for simple MVP pass

* Move type def to library

* WIP

* Move provider to proper place to pick up other routes’ actions

* Build actions off navbar, add explore actions

* Work around undefined typescript stuff

* Fix based on feedback

* close palette on ESC

* Fix based on PR feedback pt 1

* Move styles to classes

* Move another inline style to a class

* Enable command palette by default

* change around async hook structure

* Add simple feature tracking

* Code cleanup, and be sure the command is accurate

* Change to only render if there are actions, and only add actions once past login
2022-04-21 16:50:34 -05:00
Artur Wierzbicki
9f0b6a5754
Storage: refactor filtering, improve performance (#47403)
* Storage: refactor filtering, improve performance

* added a comment to `newpathfilter`

* after merge fixes
2022-04-21 23:27:43 +04:00
Yuriy Tseretyan
53a6c0210d
Alerting: tests for ticker (#47986) 2022-04-21 19:58:05 +01:00
Kat Yang
8e606dd751
Chore: Remove x from session (#48074) 2022-04-21 13:20:18 -04:00
George Robinson
d66fc6ed1a
Alerting: Add GetRuleGroups to RuleStore (#48036)
This commit adds a new method GetRuleGroups to RuleStore which returns the set of rule groups across all organizations.
2022-04-21 17:59:22 +01:00
idafurjes
dbcaedac6c
Implement preference service (#47870)
* Implement preference service

* Adjust wire.go

* Fix integration test user

* Fix api pref tests

* Fix a11y error

Co-authored-by: Alexandra Vargas <alexa1866@gmail.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2022-04-21 15:03:17 +02:00
Vardan Torosyan
a0553de8dd
Rename FGAC to RBAC in the codebase (#48051) 2022-04-21 14:31:02 +02:00
Kat Yang
eb05f6ead8
Chore: Remove x from dashboard snapshots (#48001) 2022-04-21 08:20:47 -04:00
Gabriel MABILLE
9ed7e48454
AccessControl: Modify provisioning to prevent built-in role assignment (#48031)
* Add basic and managed prefixes to avoid magic strings
For now let's stick with grafana_builtins
add function isBasic to RoleDTO
add function isBasic to Role

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

* Add team store to wire

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

Co-authored-by: Jguer <joao.guerreiro@grafana.com>
2022-04-21 14:14:45 +02:00
Eric Leijonmarck
8677552dda
Service accounts: rename feature toggle (#48037)
* refactor: renaming service-accounts to serviceAccounts

* refactor: renaming service-accounts to serviceAccounts in docs

* tests
2022-04-21 10:41:37 +01:00
Matthew Jacobson
8972418113
Alerting: Add integration test for AddDashAlertMigration (#47730)
* Alerting: Add integration test for AddDashAlertMigration

* Add more targeted test cases

* Apply suggestions from code review

Co-authored-by: gotjosh <josue.abreu@gmail.com>

* Reorganize file and improve comments

* Replace custom sort+trim with go-cmp

* Add test for AddDashAlertMigration

* Rename test cases to standard format

* Apply suggestions from code review

Co-authored-by: gotjosh <josue.abreu@gmail.com>

* Remove test-only snapshots of PostableUserConfig et al.

* Organize imports

* Fix linting

Co-authored-by: gotjosh <josue.abreu@gmail.com>
2022-04-21 04:02:23 +02:00
Kat Yang
68478e908a
Chore: Remove x from team (#47905)
* Chore: Remove x from team

* Update pkg/services/sqlstore/team.go

Co-authored-by: ying-jeanne <74549700+ying-jeanne@users.noreply.github.com>

* Update pkg/services/sqlstore/team.go

Co-authored-by: ying-jeanne <74549700+ying-jeanne@users.noreply.github.com>

* Refactor dialects and add ISAdminOfTeams to Store

* Add IsAdminOfTeams to mockstore

Co-authored-by: ying-jeanne <74549700+ying-jeanne@users.noreply.github.com>
2022-04-20 15:11:37 -04:00
Alexander Emelin
ce89d7e874
Comments: fix wrong SQL query generated if Settings are not empty (#47552) 2022-04-20 11:59:32 -07:00
Joe Blubaugh
3d91047e6e
Alerting: Notification URL points to alert view page instead of alert edit page (#47752)
Before this change, notifications generated by the Grafana Alertmanager
pointed to '/alerting/:ruleID/edit'. This change instead points them to
the view path '/alerting/grafana/:ruleID/view'. The view page has a
better UX, including timeseries display. It's also where many alert
state improvements will land in the next few versions of Grafana.

Fixes #45301

Signed-off-by: Joe Blubaugh <joe.blubaugh@grafana.com>
2022-04-20 21:43:55 +08:00
Sofia Papagiannaki
54962c2f0c
Alerting: Rename Recipient path parameter to DatasourceID (#47949) 2022-04-20 16:20:17 +03:00
kay delaney
c48d8d1d48
Frontend: Add notification persistence behind feature flag (#47871) 2022-04-20 10:42:32 +01:00
JM
1696a9abee
Dashboard: remove name requirement from CleanLibraryPanelsForDashboard (#44692)
Co-authored-by: kay delaney <kay@grafana.com>
2022-04-20 10:05:59 +01:00
Vardan Torosyan
cbd2d09d70
Update API Keys UI to adjust based on users permissions (#47802)
* Update API Keys UI to adjust based on users permissions

Since API Keys support now RBAC we need to ensure that UI
is adjusted based on the user permissions.

* Applying PR suggestions
2022-04-20 09:45:45 +02:00
Peter Holmberg
39d3c8afd7
Alerting: Fix issue with Slack contact point validation (#47559)
* secureFields and secureSettings

* revert channelIndex

* readd lost code

* use specific return

* register secure fields and use not hard coded index

* fix for determineReadOnly

* fix lint error

* fix test suite

Co-authored-by: gillesdemey <gilles.de.mey@gmail.com>
2022-04-20 09:40:57 +02:00
Yuriy Tseretyan
0c31399e34
Alerting: Fix nav-links for RBAC and other (#47798) 2022-04-19 11:47:28 -04:00
Kat Yang
a4081aebb7
Chore: Remove x from Org User (#47850)
* Chore: Remove x from org users

* Chore: Remove x.Dialect() from org users

* :poo:

* Update pkg/services/sqlstore/org_users.go

Co-authored-by: ying-jeanne <74549700+ying-jeanne@users.noreply.github.com>

* Update pkg/services/sqlstore/org_users.go

Co-authored-by: ying-jeanne <74549700+ying-jeanne@users.noreply.github.com>

* Update pkg/services/sqlstore/org_users.go

Co-authored-by: ying-jeanne <74549700+ying-jeanne@users.noreply.github.com>

Co-authored-by: ying-jeanne <74549700+ying-jeanne@users.noreply.github.com>
2022-04-19 10:55:49 -04:00
Kat Yang
c98d835f81
Chore: Remove remaining x from user (#47854) 2022-04-18 15:19:01 -04:00
ying-jeanne
7ddae870e7
fix status code 200 (#47818) 2022-04-15 08:01:58 -04:00
Gabriel MABILLE
5579dcaa6f
Chore: Fix TeamStore interface (#47810) 2022-04-15 10:33:28 +02:00
Armand Grillet
adbe374754
Alerting: fix SCC-S1017 linting issue in codebase (#47683) 2022-04-15 09:57:45 +02:00
Eric Leijonmarck
b43e9b50b4
Service accounts: RBAC the service account UI (#47788)
* WIP

* fix: bug for saving name did not remove edit

* refactor: better error msg

* Display the column Roles even when user can't see the role picker

* Remove spaces when building the search query request

* Disable Edit button and fix token addition and deletion

* Fix the error message text

Co-authored-by: Vardan Torosyan <vardants@gmail.com>
2022-04-14 23:06:08 +01:00
Alexander Weaver
758364e78b
Alerting: Refactor GET/POST alerting config routes to be more extensible (#47229)
* Refactor GET am config to be extensible

* Extract post config route

* Fix tests

* Remove temporary duplication

* Fix broken test due to layer shift

* Fix duplicated error message

* Properly return 400 on config rejection

* Revert weird half method extraction

* Move things to notifier package and avoid redundant interface

* Simplify documentation

* Split encryption service and depend on minimal abstractions

* Properly initialize things all the way up to the composition root

* Encryption -> Crypto

* Address misc feedback

* Missing docstring

* Few more simple polish improvements

* Unify on MultiOrgAlertmanager. Discover bug in existing test

* Fix rebase conflicts

* Misc feedback, renames, docs

* Access crypto hanging off MultiOrgAlertmanager rather than having a separate API to initialize
2022-04-14 13:06:21 -05:00
Serge Zaitsev
41012af997
Tracing: Use common traceID context value for opentracing and opentelemetry (#46411)
* use common traceID context value for opentracing and opentelemetry

* support sampled trace IDs as well

* inject traceID into NormalResponse on errors

* Finally the test passed

* fix the test

* fix linter

* change the function parameter

Co-authored-by: Ying WANG <ying.wang@grafana.com>
2022-04-14 17:54:49 +02:00
Vardan Torosyan
782ec05d8c
Create fixed roles for reading API Keys and service accounts and fix listing of service account tokens (#47767)
* Create fixed roles for reading API Keys and service accounts

* Handle PR comments and fix the listing of token
2022-04-14 15:09:55 +02:00
idafurjes
ecd6cd4a92
Split preference store (#46843)
* Split preference store

* Chore: Add tests to pref

* Fix preference in wire

* Rename and adjust

* Add pref service test

* Rename methods, add tests

* Rename Preferences to Preference, names IDs correctly

* Fix lint

* Refactor Save

* Refactor upsert
Add new logic for QueryHistory
Rename some fields according to go naming conventions
Refactore tests

* Roll back ID that breaks tests

* Rename Id to ID in UpdatePreferenceQuery

* Use preference as a model to modify store

* Move pref store fakes to pref test file

* Add integration tag for store tests

* Adjust test

Co-authored-by: yangkb09 <yangkb09@gmail.com>
2022-04-14 14:22:00 +02:00
Jean-Philippe Quéméner
060ccacbf9
Alerting: unwrap upsert into insert and update function (#47731)
* Alerting: unwrap upsert into insert and update function

* add changelog entry

* remove changelog entry

* rename upsertrule to updaterule

* use directly alertrule model for inserts

* add test for updating a rule with a conflicting name
2022-04-14 14:21:36 +02:00
Sofia Papagiannaki
c8189e4808
API: enable proxying datasource calls using the datasource UID (#47634)
* Introduce additional routes
2022-04-14 13:28:13 +03:00
Ivana Huckova
aceedb3a32
Query history: Add migration endpoint (#47551)
* Add endpoint for migration

* Check for createdAt

* Query history: Remove returning of dtos

* Query history: Fix CreatedAt

* Refactor based on suggestions

* Insert into table in batches
2022-04-14 09:33:41 +02:00
Alexander Weaver
c266a4ac81
Alerting: Remove mis-behaving fake and fix masked test failure in AM config API (#47747)
* Remove misbehaving fake

* Fix bug and inject logger
2022-04-13 19:31:57 -05:00
Jean-Philippe Quéméner
388ecb4037
Alerting: Provisioning API - Contact points (#47197) 2022-04-13 22:15:55 +02:00
Santiago
5fb80498b1
Apply templating on alert notifications on OK state (#47355)
* OK notifications using previous evaluation data

* copy rule.EvalMatches to avoid changes to the underlying array

* test cases added/modified

* delete trailing newline

* fix double newline in go import

* add change to the changelog

* specify that this only affects legacy alerting (changelog)

* use current eval data instead of prev eval data

* create evalMatch just once

* code comments, renamings, getTemplateMatches() function

* changelog and docs updated
2022-04-13 17:04:10 -03:00
Alexander Emelin
e00db6a826
Live: collect more usage stats – enabled, ha enabled, num nodes, channels, subs (#47378) 2022-04-13 12:27:03 -07:00
Yuriy Tseretyan
884c885289
Alerting: Support OK option for Error state (#47670)
* support OK state for Error
2022-04-13 14:45:29 -04:00
Ieva
a245531f0c
Access control: service account role check (#47710)
* forbid setting role higher than user's role

* change response code

* can assign API key permissions to non-admin users

* add: assign viewer role directly upon creation

* refactor: add AddSATcommand infavor of AddAPIkey

* refactor: frontend fixes for ServiceAccountToken

Co-authored-by: eleijonmarck <eric.leijonmarck@gmail.com>
2022-04-13 18:11:03 +02:00
Jguer
3456793e0f
AccessControl: fix value copying in method access and add LogID (#47694)
* AccessControl: fix value copying in method access and add LogID

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

* Lint.

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
Co-authored-by: gamab <gabi.mabs@gmail.com>
2022-04-13 17:22:53 +02:00
Serge Zaitsev
e86b6662a1
Chore: Remove bus.Bus field (#47695)
* Chore: Remove bus.Bus field

* fix integration test
2022-04-13 15:24:13 +02:00
Eric Leijonmarck
673a2ab49e
fix: bug where disabled didnt disable the use of service account (#47688) 2022-04-13 13:40:58 +01:00
Artur Wierzbicki
46dc1e98fa
Previews: track oss adoption 2022-04-13 11:54:49 +02:00
Artur Wierzbicki
a4381ebc91
Previews: create crawler auth setup service (#47349)
* #46968: add `RetrieveServiceAccountIdByName` to serviceaccounts service

* #46968: improve error logging in rendering service

* #46968: add oss crawler account setup

* #46968: fix tests

* #46968: switch back to ROLE_ADMIN

* #46968: rename to crawlerAuth

* comment crawler_auth.go
2022-04-12 19:34:04 +02:00
Ieva
d0abe1bb3d
Annotation FGAC checks for comments (#47468)
* typo

* remove unwanted change

* remove unwanted change
2022-04-12 17:30:50 +01:00
Artur Wierzbicki
712b239d5a
Storage: remove pointer on write path (#47580)
* remove pointer to contents in UpsertFileCommand

* add command to UpsertFileCommand

* fix client after API refactor
2022-04-12 16:58:09 +02:00
ying-jeanne
e979690011
Linter: fix linter for golangci-lint version v1.45.0 (#47623)
* Update golangci-lint to v1.45.2

Version 1.45.0 added support for Go 1.18:

https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md#v1450

Signed-off-by: Marcelo E. Magallon <marcelo.magallon@grafana.com>

* Linter: fix some lints issue for golangci-lint version 1.45.2

Co-authored-by: Marcelo E. Magallon <marcelo.magallon@grafana.com>
Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>
2022-04-12 08:15:16 -04:00
Ivana Huckova
201557c6fc
Query history: Save user preferences in database (#47506) 2022-04-12 11:42:42 +02:00
Gabriel MABILLE
8bd825e16c
AccessControl: Make the built-in role definitions public (#47525)
* AccessControl: Make the built-in role definitions public

* Add context to RegisterFixedRoles

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

* Making BuiltInRolesWithParents public to the AccessControl package

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

Co-authored-by: Jguer <joao.guerreiro@grafana.com>
2022-04-12 09:53:43 +02:00
ying-jeanne
0bf889e058
Fix unmaarshal of double pointer (#47586)
* Fix unmaarshal of double pointer

* update sdk version
2022-04-12 09:30:34 +02:00
Yuriy Tseretyan
af9353caec
Alerting: Add check for datasource permission in alert rule read API (#47087)
* add check for access to rule's data source in GET APIs

* use more general method GetAlertRules instead of GetNamespaceAlertRules.
* remove unused GetNamespaceAlertRules.

Tests:
* create a method to generate permissions for rules
* extract method to create RuleSrv
* add tests for RouteGetNamespaceRulesConfig
2022-04-11 17:37:44 -04:00
Yuriy Tseretyan
48519f9ebb
Alerting: reduce database calls in prometheus-comptible rules API (#47080)
* move validation at the beginning of method
* remove usage of GetOrgRuleGroups because it is not necessary. All information is already available in memory.
* remove unused method
2022-04-11 10:54:29 -04:00
Kristin Laemmert
bda3dd24e4
chore: remove golang.org/x/net/context in favor of stdlib (#47532)
This PR removes golang.org context imports under pkg/services/* and replaces them with the stdlib context.

Closes #44178
2022-04-11 08:46:21 -04:00
Ieva
ef4c2672b3
Access control: SQL filtering for annotation listing (#47467)
* pass in user to attribute scope resolver

* add SQL filter to annotation listing

* check annotation FGAC permissions before exposing them for commenting

* remove the requirement to be able to list all annotations from annotation listing endpoint

* adding tests for annotation listing

* remove changes that got moved to a different PR

* unused var

* Update pkg/services/sqlstore/annotation.go

Co-authored-by: Ezequiel Victorero <evictorero@gmail.com>

* remove unneeded check

* remove unneeded check

* undo accidental change

* undo accidental change

* doc update

* move tests

* redo the approach for passing the user in for scope resolution

* accidental change

* cleanup

* error handling

Co-authored-by: Ezequiel Victorero <evictorero@gmail.com>
2022-04-11 13:18:38 +01:00
Michael Mandrus
4318ffdd46
SAML: Allow disabling of SAML signups (#47481)
* Add new error message for signup not allowed errors

* Add documentation on new SAML signup option

* Accept documentation feedback

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

* Accept documentation feedback

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

* run prettier:write

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
2022-04-08 18:47:07 -04:00
Serge Zaitsev
18e93c7077
Chore: Remove bus (#47511)
* Chore: Remove bus

* remove unused const
2022-04-08 16:15:06 +02:00
Serge Zaitsev
b31c7d3654
Chore: Remove bus from alerting rule (#47508)
* Chore: Remove bus from alerting rule

* fix alerting tests

* fix provide service
2022-04-08 14:30:25 +02:00
Serge Zaitsev
ad432108e6
Chore: Remove bus from dashboards provisioning (#47495)
* Chore: Remove bus from dashboards provisioning

* fix symlink test, make it run on darwin

* remove unused mock
2022-04-08 13:56:38 +02:00
Artur Wierzbicki
f1a1070d41
UsageStats: track enabled features (#47407)
* #47127: include enabled features in the usage stats reports

* #47127: convert feature names to snake cased metric names

* #47127: remove dead code

* #47127: lint fix

* #47127: convert GetUsageStats to return `map[string]interface{}`

* #47127: fix testssssssss

* #47127: fix testssssssss
2022-04-08 12:42:33 +02:00
Serge Zaitsev
2cf88cfec8
Chore: Remove bus from contexthandler (#47458)
* Chore: remove bus from contexthandler

* remove bus from orgredirect
2022-04-08 10:33:19 +02:00
Ivana Huckova
7ab910af48
Query history: Search in comments (#46761) 2022-04-08 09:35:34 +02:00
Joe Blubaugh
631dd718a2
47470: Add additional delay to silences in test. (#47482)
This test of silence cleanup was flaky because of its use of real wall
time. In CI environments with slow execution, delays could cause the
test to fail. This change mitigates the problem by increasing the end time of
silences in the test.

After Prometheus merges this PR: https://github.com/prometheus/alertmanager/pull/2867
we can make the test fully deterministic by using a fake clock.

Fixes #47470

Signed-off-by: Joe Blubaugh <joe.blubaugh@grafana.com>
2022-04-08 14:52:08 +08:00
Jeff Levin
4a4d87dbdc
add public dashboards feature flag (#47364) 2022-04-07 10:30:19 -08:00
Alexander Weaver
c3ad36ba72
Temporarily skip intermittent test (#47471) 2022-04-07 12:52:00 -05:00
gotjosh
94f72acbb3
Alerting: Introduce an internal changelog (#47390)
* Alerting: Introduce an internal changelog

Please note that this is not intented to replace Grafana's "add to changelog" label. It is _mostly_ for internal consumption of the Alerting team that owns this part of Grafana.

* Fix markdown formatting

* Fix changelog entry
2022-04-07 15:24:26 +01:00
Giordano Ricci
ca286a238d
Explore: Add explore2Dashboard feature toggle (#47395) 2022-04-07 09:26:01 +01:00
Timur Olzhabayev
25235b3167
Removing plugin list panel (#46914)
The core plugin named plugin list panel is removed
2022-04-07 09:54:27 +02:00
Serge Zaitsev
d153d896c5
Chore: Remove bus from contexthandler (#47374)
* Chore: Remove bus from contexthandler

* fix tests

* try different wire binding

* maybe remove a few more dispatches

* fix tests
2022-04-06 16:31:26 +02:00
Will Browne
f3c1448b57
Analytics: Enable grafana and plugin update checks to be operated independently (#46352)
* add separate cfg for controlling plugin update checks

* https

* add specific version note to docs

* pr feedback

* fixup
2022-04-06 10:50:21 +02:00
Gabriel MABILLE
f7305965a4
AccessControl: Remove package lists for roles and grants (#47141)
* AccessControl: Remove package variables for roles and grants

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

* Check for inheritance during role registration

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

* Moving back role definition to accessscontrol

* Make settings reader role public

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

* Nits

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

* Forgot to update this

* Account for declaration error

* Fixing pkg/api init ossac

* Account for error in tests

* Update test to verify inheritance

* Nits.

* Place br inheritance behind a feature toggle

* Parent -> Parents

* Nit.

Co-authored-by: Jguer <joao.guerreiro@grafana.com>
2022-04-06 09:31:14 +02:00
Serge Zaitsev
3a7fc80948
Chore: Remove last bus parts from login package (#47313)
* Chore: Remove last bus parts from login package

* fix middleware tests
2022-04-06 08:45:01 +02:00
Piotr Jamróz
8490fd77e3
Users: clean up OrgId when all user orgs are removed (#46003)
* Clean up orgId when user organization is removed

* Add a test for removing user org

* Fix linting errors

* Update comment

* Fix linting errors

* Make removing user org more explicit
2022-04-06 08:35:58 +02:00
Alexander Weaver
dde0b93cf1
Alerting: Provisioning API - Notification Policies (#46755)
* Base-line API for provisioning notification policies

* Wire API up, some simple tests

* Return provenance status through API

* Fix missing call

* Transactions

* Clarity in package dependencies

* Unify receivers in definitions

* Fix issue introduced by receiver change

* Drop unused internal test implementation

* FGAC hooks for provisioning routes

* Polish, swap names

* Asserting on number of exposed routes

* Don't bubble up updated object

* Integrate with new concurrency token feature in store

* Back out duplicated changes

* Remove redundant tests

* Regenerate and create unit tests for API layer

* Integration tests for auth

* Address linter errors

* Put route behind toggle

* Use alternative store API and fix feature toggle in tests

* Fixes, polish

* Fix whitespace

* Re-kick drone

* Rename services to provisioning
2022-04-05 16:48:51 -05:00
gotjosh
cb6124c921
Alerting: Accurately set value for prom-compatible APIs (#47216)
* Alerting: Accurately set value for prom-compatible APIs

Sets the value fields for the prometheus compatible API based on a combination of condition `refID` and the values extracted from the different frames.

* Fix an extra test

* Ensure a consitent ordering

* Address review comments

* address review comments
2022-04-05 19:36:42 +01:00
Josh Hunt
71db5115f4
User: Expose GCOM user ID as externalUserId in grafanaBootData (#47307)
* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* fix sql indtent

Co-authored-by: Joao Silva <joao.silva@grafana.com>
Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
2022-04-05 14:44:33 +01:00
Jguer
90a94eab74
Dashboard/Folder permission fix session (#47174)
* Fix inherited scopes for dashboard to use folder uid

* Add inherited evaluators

* Slight modification of the commments

* Add test for inheritance

* Nit.

* extract shared function from tests

* Nit. Extra line

* Remove unused comment

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
Co-authored-by: gamab <gabi.mabs@gmail.com>
2022-04-05 14:28:23 +02:00
Serge Zaitsev
bf9e0e8bc8
Chore: Remove some bus from login package (login attempts) (#47310) 2022-04-05 13:07:27 +02:00
Gabriel MABILLE
e430f5021d
AccessControl: Alerting role grants folder read on all folders to viewers (#47278) 2022-04-05 07:04:02 +00:00
Serge Zaitsev
33006436cc
Chore: Remove bus.Dispatch from some login packages (#47248)
* Chore: Remove bus.Dispatch from some login packages

* remove debug log

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

* remove login.Init()

* remove unused reset function

* remove AuthenticateUserFunc global

* swap conditional branches

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

* fix formatting

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2022-04-04 20:36:15 +02:00
Konrad Lalik
6992d17924
Alerting: Add support to distinguish Prometheus datasource subtypes (Mimir, Cortex and Vanilla Prometheus) (#46771)
* Add basic UI for custom ruler URL

* Add build info fetching for alerting data sources

* Add keeping data sources build info in the store

* Use data source build info to construct data source urls

* Remove unused code

* Add custom ruler support in prometheus api calls

* Migrate actions

* Use thunk condition to prevent multiple data source buildinfo fetches

* Unify prom and ruler rules loading

* Upgrade RuleEditor tests

* Upgrade RuleList tests

* Upgrade PanelAlertTab tests

* Upgrade actions tests

* Build info refactoring

* Get rid of lotex ruler support action

* Add prom ruler availability checking when the buildinfo is not available

* Add rulerUrlBuilder tests

* Improve prometheus data source validation, small build info refactoring

* Change prefix based on Prometheus subtype

* Use the correct path

* Revert config routing

* Add deprecation notice for /api/prom prefix

* Add tests to the datasource subtype

* Remove custom ruler support

* Remove deprecation notice

* Prevent fetching ruler rules when ruler api is not available

* Add build info tests

* Unify naming of ruler methods

* Fix test

* Change buildinfo data source validation

* Use strings for subtype params and unveil mimir

* organise imports

* frontend changes and wordsmithing

* fix test suite

* add a nicer verbose message for prometheus datasources

* detect Mimir datasource

* fix test

* fix buildinfo test for Mimir

* shrink vectors

* add some code documentation

* DRY prepareRulesFilterQueryParams

* clarify that Prometheus does not support managing rules

* Improve buildinfo error handling

Co-authored-by: gotjosh <josue.abreu@gmail.com>
Co-authored-by: gillesdemey <gilles.de.mey@gmail.com>
2022-04-04 18:30:17 +01:00
Ieva
bc9b5325a0
update docs, simplify actions and scopes (#47067) 2022-04-04 13:53:58 +01:00
Sergey Kostrukov
5675496f6b
Migrate to Grafana Azure SDK (#47232) 2022-04-04 11:23:13 +02:00
Yuriy Tseretyan
e94d0c1b96
Alerting: update rule test endpoints to respect data source permissions (#47169)
* make eval.Evaluator an interface
* inject Evaluator to TestingApiSrv
* move conditionEval to RouteTestGrafanaRuleConfig because it is the only place where it is used
* update rule test api to check data source permissions
2022-04-02 02:00:23 +02:00
Yuriy Tseretyan
51114527dc
Alerting: handle folder permissions when fine-grained access enabled (#47035)
* Use alert:create action for folder search with edit permissions. This matches the action that is used to query dashboards (the update will be addressed later)
* Update rule store to use FindDashboards instead of folder service to list folders the user has access to view alerts. Folder service does not support query type and additional filters. 
* Do not check whether the user can save to folder if FGAC is enabled because it is checked on API level.
2022-04-01 19:33:26 -04:00
Yuriy Tseretyan
8a2c368031
check that user is authorized to create\update silences (#47163) 2022-04-01 09:39:59 -04:00
Sergey Kostrukov
656ade9884
Shared Azure middleware between Azure Monitor and Prometheus datasources (#46002)
* Scopes in Azure middleware

* Enable Azure middleware without feature flag

* Use common Azure middleware in Azure Monitor

* Apply feature flag to JsonData configuration of Azure auth

* Enforce feature flag in Prometheus datasource

* Prometheus provider tests

* Datasource service tests

* Fix http client provider tests

* Pass sdkhttpclient.Options by reference

* Add middleware to httpclient.Options

* Remove dependency on Grafana settings

* Unit-tests updated

* Fix ds_proxy_test

* Fix service_test
2022-04-01 13:26:49 +02:00
Marcus Efraimsson
16db1ad46d
API: Fixes request logging middleware to include userId, orgId, uname (#47183)
Fixes #47006
2022-04-01 13:24:39 +02:00
Alexander Weaver
b8e277ee4c
Alerting: Create feature toggle for provisioning (#47167)
* Create feature flag for alerting provisioning

* Fix tabs for golint compliance
2022-04-01 08:32:00 +02:00
Santiago
4b1af6fb06
Fix empty contact point URLs when template parsing fails (#47029)
* fix empty URLs

* leave URL templating, use fallback

* better fix, new tests cases

* fix linting errors
2022-03-31 15:57:48 -03:00
Gabriel MABILLE
0d87de153a
AccessControl: Add a feature flag for the builtin role simplification (#47062)
* AccessControl: Add a feature flag for the builtin role simplification

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

* Update standardDeatureFlags instead

Co-authored-by: Jguer <joao.guerreiro@grafana.com>
2022-03-31 11:40:57 +02:00
George Robinson
79769132c0
Alerting: Alert rule should wait For duration when execution error state is Alerting (#47052)
Alerting: Alert rule should wait For duration when execution error state is Alerting
2022-03-31 09:57:58 +01:00
Alexander Weaver
502cf8b37f
Alerting: Unify Swagger/OpenAPI generation tooling (#46928)
* Unify makefiles

* Improve documentation
2022-03-31 09:34:46 +02:00
Ryan McKinley
edf384c730
DashboardSave: use a feature flag for drawer behavior (#46972) 2022-03-30 10:07:41 -07:00
Nathan Marrs
4449439a41
Search: Implement basic improved UI (#46758) 2022-03-30 09:50:32 -07:00
Selene
8e52dbb87b
Chore: Remove bus from authproxy (#46936)
* Make authproxy injectable

* Fix import

* Provide function was in wrong place

* Fixing tests

* More imports and rollback a change

* Fix lint
2022-03-30 17:01:24 +02:00
Karl Persson
a5e4a533fa
Access control: use uid for dashboard and folder scopes (#46807)
* use uid:s for folder and dashboard permissions

* evaluate folder and dashboard permissions based on uids

* add dashboard.uid to accept list

* Check for exact suffix

* Check parent folder on create

* update test

* drop dashboard:create actions with dashboard scope

* fix typo

* AccessControl: test id 0 scope conversion

* AccessControl: store only parent folder UID

* AccessControl: extract general as a constant

* FolderServices: Prevent creation of a folder uid'd general

* FolderServices: Test folder creation prevention

* Update pkg/services/guardian/accesscontrol_guardian.go

* FolderServices: fix mock call expect

* FolderServices: remove uneeded mocks

Co-authored-by: jguer <joao.guerreiro@grafana.com>
2022-03-30 15:14:26 +02:00
gotjosh
84e5f336fe
Alerting: Classic conditions can now display multiple values (#46971)
* Alerting: Extract classic condition values by RefID

* uncapitalise function

* update documentation

* Update pkg/services/ngalert/eval/extract_md.go

Co-authored-by: George Robinson <george.robinson@grafana.com>

* Update pkg/services/ngalert/state/state.go

Co-authored-by: George Robinson <george.robinson@grafana.com>

* Update pkg/services/ngalert/state/state.go

Co-authored-by: George Robinson <george.robinson@grafana.com>

* Update pkg/services/ngalert/eval/extract_md.go

Co-authored-by: George Robinson <george.robinson@grafana.com>

* Update docs/sources/alerting/unified-alerting/alerting-rules/alert-annotation-label.md

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

* Update pkg/services/ngalert/eval/extract_md.go

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

* Run prettier

Co-authored-by: George Robinson <george.robinson@grafana.com>
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
2022-03-29 20:33:03 +01:00
Matthew Jacobson
932f43b220
Alerting: Add resolved count to notification title when both firing and resolved present (#46697)
* Alerting: Add resolved count to notification title when both firing and resolved are present

* Fix test case default_template_test.go
2022-03-29 11:22:28 -04:00
Yuriy Tseretyan
c1dbe7617c
fix scope for datasource:query action (#46973) 2022-03-29 09:58:59 -04:00
Artur Wierzbicki
60984881ec
Previews: fix crawler in multi-org deployments (#46967)
* Previews: fix crawler in multi-org deployments

* Previews: fix statement ordering
2022-03-29 13:40:11 +01:00
Kat Yang
e6726681a9
Chore: Remove x from annotation test (#46935) 2022-03-25 13:23:21 -04:00
Kat Yang
90f2233ea9
Chore: Remove global database engine variable from annotation (#46940)
* Chore: Remove global database engine variable from annotation

* 💩
2022-03-25 13:23:09 -04:00
Kat Yang
19be0b4170
Chore: Remove x from org users (#46848)
* Chore: Remove x from org users

* Chore: Remove x.Dialect() from org users
2022-03-25 17:19:01 +00:00
Yuriy Tseretyan
e20d157a9b
Alerting: rules delete API to check data source authorization (#46906)
* merge RuleSrv rule delete methods
* remove unused store methods
* implement delete by uid for fake store
* add scheduler mock
* implement tests for RouteDeleteAlertRules
2022-03-25 12:39:24 -04:00
Gabriel MABILLE
53e7f8405f
AccessControl: Permission Migrator, clean unused arguments (#46937) 2022-03-25 14:04:10 +01:00
Yuriy Tseretyan
6610adf090
Alerting: remove UpdateRuleGroup from fake rule store (#46941)
* remove UpdateRuleGroup from fake rule store because It is not part of interface anymore
2022-03-24 19:29:19 -04:00
Yuriy Tseretyan
15e4556c2f
Alerting: update authorization logic to use proper legacy roles when fine-grained access is disabled (#46931)
* require legacy Editor for post, put, delete endpoints
* require user to be signed in on group level because handler that checks that user has role Editor does not check it is signed in
2022-03-24 17:13:47 -04:00
Yuriy Tseretyan
8868848e93
Alerting: rule group update API to ignore deletes of rules user is not authorized to access (#46905)
* verify that the user has access to all data sources used by the rule that needs to be deleted from the group
* if a user is not authorized to access the rule, the rule is removed from the list to delete
2022-03-24 16:53:00 -04:00
Gabriel MABILLE
9dc06cd21f
simplify bulkAssignRoles (#46891) 2022-03-24 18:06:44 +01:00
Kat Yang
39f14a2ec2
Chore: Remove x from login attempt (#46853) 2022-03-24 17:00:41 +00:00
kay delaney
8329cd59f6
LibraryPanels: Increase max description length to 2048 chars (#46601) 2022-03-24 12:14:56 +00:00
Karl Persson
cac6936015
Access control: Change data source permissions to be based on UID (#46741)
* Add ResourceAttribute

* Add ResourceAttribute option

* Set ResourceAttribute option

* Change resolvers to return uid based scopes

* update swagger to correct scope

* use ResourceAttribute for endpoint scope

* bump role version

* Add support for different attributes for access control metadata

* evaluate data source metadata based on uid

* Fix test

* uncomment benchmarks

* Use resourceID

* use evaluator for access control metadata

* update comment

* Set default permissions based on uid

* Add attribute to accesscontrol filter

* validate that scopes has correct attribute

* lint

* Update comment

* remove attribute parameter and extend prefix

* refactor to use scope prefix

* Get metadata with prefix

* fix test

* fix comparision

* remove unused type

* fix attribute index

* fix typo

* restructure logic

* Get metadata by uid

* fix imports

Co-authored-by: jguer <joao.guerreiro@grafana.com>
2022-03-24 12:21:26 +01:00
Gabriel MABILLE
3440e7c8f7
AccessControl: Fix locked role picker in orgs/edit page (#46539)
* AccessControl: Fix locked role picker in orgs/edit page

* Use correct org when computing metadata
2022-03-24 08:58:10 +01:00
Ezequiel Victorero
c5f295b5b3
Access Control: adding FGAC validation to mass delete annotation endpoint (#46846)
* Access Control: adding FGAC validation to mass delete annotation endpoint
2022-03-23 18:39:00 -03:00
Yuriy Tseretyan
60d4cd80bf
Alerting: update DeleteAlertRuleByUID to accept many UID (#46890) 2022-03-23 16:09:53 -04:00
Selene
d57c94fb6a
Chore: Remove bus from folder service (#46840)
* Remove bus from folder service

* Fix tests
2022-03-23 19:40:22 +01:00
Yuriy Tseretyan
4ee48c2e77
Alerting: Update GetRuleGroupAlertRules to accept optional rule group (#46889)
* rename GetRuleGroupAlertRules to GetAlertRules
* make rule group optional in GetAlertRulesQuery
* simplify FakeStore. the current structure did not support optional rule group
2022-03-23 17:36:25 +00:00
Yuriy Tseretyan
acd7be1cb4
Alerting: Change getEvaluatorForAlertRule to checkDatasourcePermissionsForRule (#46887)
update method getEvaluatorForAlertRule to accept permissions evaluator and exit on the first negative result, which is more effective than returning an evaluator that in fact is a bunch of slices.
2022-03-23 17:11:30 +00:00
Joe Blubaugh
481a68cbf5
Unified Alerting: Make log message follow codebase convention. (#46881)
1. Keep log lines lower case.
2. The key-value pair arguments are not format argument for the string.
3. Always use the "err" key.
2022-03-23 15:07:07 +01:00
idafurjes
77976ea810
Add fakes for db interface (#46885) 2022-03-23 15:06:47 +01:00
Joe Blubaugh
c5b39dd3cd
Unified Alerting, Issue 41156: Clean up expired silences. (#46740)
Expired silences older than the retention period were not being cleaned up. The root problem was that notifier.Alertmanager overrides the Prometheus alert manager's silence maintenance function and was not calling Silences.GC() in the overriden function.
2022-03-23 09:49:02 +01:00
Jean-Philippe Quéméner
a80f04c949
Alerting: add collision safe update function for alertmanager configurations (#46692)
* Alerting: add collision safe update function for alertmanager configurations

* fix typo

* use bootstrap func for tests

* move hash calculation to store

* remove icons lol

* remove removed field
2022-03-23 09:31:46 +01:00
Gabriel MABILLE
ff3c1e3144
AccessControl: Handle ':' in attribute resolution (#46742)
* AccessControl: Handle ':' in attribute resolution

* Simplify based on assumption that prefixes will have maximum 2 parts
2022-03-23 08:48:32 +01:00
Kat Yang
884c2351d8
Chore: Remove x from org (#46851) 2022-03-22 21:17:53 +00:00
Karl Persson
ee9badecdf
Access Control: Add test flag to enable access control (#46780)
* Add feature flags options to test db
2022-03-22 20:48:32 +01:00
idafurjes
5db1a2e804
Add DB interface (#46832) 2022-03-22 15:43:53 +01:00
Eng Zer Jun
b56848f006
test: use T.TempDir to create temporary test directory (#44947)
The directory created by `T.TempDir` is automatically removed when the
test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-03-22 15:43:29 +01:00
Marcus Efraimsson
be7bcbf94e
Chore: Add tests for plugin settings sqlstore (#46792)
Follow up of #46777 adding tests for plugin settings in sqlstore package.
2022-03-22 15:34:27 +01:00
Selene
b2af18f129
Chore: Remove bus from dashboard service (#46829)
* Move DeleteDashboard funtion into dashboards store service, remove bus and update tests

* Remove bus from folder service and update more tests

* Fix mock
2022-03-22 14:36:50 +01:00
Karl Persson
bfb03d779d
Access Control: Correctly check for id suffix (#46824)
* Correctly check for id suffix
2022-03-22 13:48:15 +01:00
Karl Persson
faf4a3f751
Access Control: Rename global users scope (#46794)
* Rename scope from global:users to global.users to match scope convention
2022-03-22 12:48:46 +01:00
ying-jeanne
adc0cbf176
remove global variable in annotation (#46746)
* remove global varaible in annotation

* remove todo

* replace intransaction with withdbtransaction

* fix typo
2022-03-22 19:20:57 +08:00
Serge Zaitsev
4ce7978cd8
Chore: Remove bus from notification service (#46813)
* Chore: Remove bus from notification service

* fix signature

* fix function signature in tests
2022-03-22 09:04:30 +01:00
Yuriy Tseretyan
2ade8b56dd
Alerting: support fine-grained access control in ruler update API (#45749)
* require Editor if FGAC is disabled. Otherwise, check `alert.rule:*` + `datasource:query` permissions when user changes rules.
2022-03-21 19:20:35 -04:00
Serge Zaitsev
9315ddd57c
Chore: Remove bus from oauthtoken (#46811) 2022-03-21 21:13:57 +01:00
Serge Zaitsev
cce46a6349
Chore: Remove bus from live package (#46803) 2022-03-21 20:34:19 +01:00
Ezequiel Victorero
c717320942
Adding FGAC annotations validation for creation and deletion (#46736)
Access Control: Adding FGAC annotations validation for creation and deletion
Co-authored-by: IevaVasiljeva <ieva.vasiljeva@grafana.com>
2022-03-21 14:28:39 -03:00
Karl Persson
7ab1ef8d6e
Access Control: Support other attributes than id for resource permissions (#46727)
* Add option to set ResourceAttribute for a permissions service
* Use prefix in access control sql filter to parse scopes
* Use prefix in access control metadata to check access
2022-03-21 17:58:18 +01:00
Emil Tullstedt
0e5ac29763
Data sources: Grant creator edit permissions to data source by default (#46168)
* Data sources: Sent user ID when creating data source

* Data sources: Grant a data source creator edit permissions

* Use edit permisison and only append if user id is in command

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
2022-03-21 17:16:05 +01:00
ying-jeanne
0d5a6c2194
remove bus from search and avoid import cycle (#46789)
* fix the import cicle

* fix some unittest

* fix removal bus from search
2022-03-21 23:54:30 +08:00
Marcus Efraimsson
1044585b50
Plugins: Fix problematic query (#46777)
Fixes mysql error "sql: expected 0 arguments, got 1" introduced via #46283
2022-03-21 15:42:05 +01:00
Serge Zaitsev
df465ccad3
Chore: Remove bus from thumbs service (#46772) 2022-03-21 14:15:31 +01:00
Serge Zaitsev
fec634a091
Chore: Remove bus.Dispatch from guardian package (#46711)
* replace bus in guardian with sqlstore

* fix a couple of tests

* replace bus in the rest of the tests

* allow init guardian from other packages

* make linter happy

* init guardian in library elements

* fix another test in libraryelements

* fix more tests

* move guardian mock one level deeper

* fix more tests

* rename init functions
2022-03-21 10:49:49 +01:00
Yuriy Tseretyan
2bd4c9ccde
respect query filter in FindDashboards (#46652) 2022-03-18 22:38:32 +01:00
Will Browne
bda3f860a8
Plugins: Add plugin settings DTO (#46283)
* add clearer service layer

* re-order frontend settings for clarity

* fix fetch fail

* fix API response

* fix mockstore

* in -> where
2022-03-18 20:49:13 +01:00
Yuriy Tseretyan
6967b15e76
Access Control: Update Alerting Navbar links builder to use fine-grained access control (#46743)
* remove unnecesarry grants for some alerting roles
* add permissions checks to navigation
2022-03-18 12:58:50 -04:00
Ieva
f2450575b3
Access control: FGAC for annotation updates (#46462)
* proposal

* PR feedback

* fix canSave bug

* update scope naming

* linting

* linting

Co-authored-by: Ezequiel Victorero <ezequiel.victorero@grafana.com>
2022-03-18 17:33:21 +01:00
Eric Leijonmarck
c592e6606c
Filtering of service accounts by expired tokens (#46251)
* Refactor to ServiceAccounts Query

* filtering expiredtokens on backend

* WIP

* WIP

* WIP

* fix: missing that we do not cover for no service accounts

* fix: wrong link

* feat: filter able to get only service accounts with expired tokens

* refactor: naming

* Update pkg/services/serviceaccounts/models.go

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

* goimported

* Update pkg/services/serviceaccounts/api/api.go

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

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2022-03-18 15:50:34 +01:00
idafurjes
52bd7618dd
Remove global variable from user (#46696)
* Remove global variable from user

* Remove missed x
2022-03-18 09:15:23 +01:00
Ryan McKinley
1cfb9a4a19
Storage: add basic storage service (#46604) 2022-03-17 10:19:23 -07:00
Karl Persson
4df7bf5ab2
Access control: Display inherited folder permissions in dashboards (#46421) 2022-03-17 17:08:51 +01:00
Ashley Harrison
586272e5f0
Navigation: Introduce a preferences table to store Navbar preferences (#44914)
* First attempt at creating new navbar_preferences table in db

* Apply to every nav item instead of just home

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* Chore: introduce initTestDB options for features

* fix unit tests

* Add another unit test and some logic for detecting if a preference already exists

* tidy up

* Only override IsFeatureToggleEnabled if it's defined

* Extract setNavPreferences out into it's own function, initialise features correctly

* Make the linter happy

* Use new structure

* user essentials mob! 🔱

* user essentials mob! 🔱

* Split NavbarPreferences from Preferences

* user essentials mob! 🔱

* user essentials mob! 🔱

* Fix lint error

* Start adding tests

* Change internal db structure to be a generic json object

* GetJsonData -> GetPreferencesJsonData

* Stop using simplejson + add some more unit tests

* Update pkg/api/preferences.go

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

* Updates following review comments

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* Change patch to upsert, add a unit test

* remove commented out code

* introduce patch user/org preferences methods

* Return Navbar preferences in the get call

* Fix integration test by instantiating JsonData

* Address review comments

* Rename HideFromNavbar -> Hide

* add swagger:model comment

* Add patch to the preferences documentation

* Add openapi annotations

* Add a short description

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* user essentials mob! 🔱

* Update unit tests

* remove unneeded url

* remove outdated comment

* Update integration tests

* update generated swagger

Co-authored-by: Alexandra Vargas <alexa1866@gmail.com>
Co-authored-by: Hugo Häggmark <hugo.haggmark@gmail.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2022-03-17 12:07:20 +00:00
Yuriy Tseretyan
7df22c1573
Access Control: Fix Filter to correctly handle duplicated scopes (#46667) 2022-03-16 16:59:19 -04:00
Joan López de la Franca Beltran
2081f37e95
Encryption: Make DEKs cache TTL & cleanup interval configurable (#46042)
* Make DEKs cache TTL & cleanup interval configurable

* Improve 'data_keys_cache_ttl' setting description

* Fix test
2022-03-16 20:05:13 +01:00
gotjosh
a338c78ca8
Alerting: Remove internal labels from prometheus compatible API responses (#46548)
* Alerting: Remove internal labels from prometheus compatible API responses

* Appease the linter

* Fix integration tests

* Fix API documentation & linter

* move removal of internal labels to the models
2022-03-16 16:04:19 +00:00
Jguer
d5883c1b27
Service Accounts: Implement basic usage stats (#46619)
* Stats: do not count SAs as users

* Stats: implement basic service account metrics

* Stats: do not count service account tokens as api keys

* Stats: fix metric names

* Stats: add SA stats test

* rename user to sa
2022-03-16 16:54:34 +01:00
Karl Persson
943a8508a6
Handle case where there are no matching ids for all actions passed to (#46646) 2022-03-16 16:31:33 +01:00
Karl Persson
2727e2503f
Use corrct variable names (#46647) 2022-03-16 16:18:45 +01:00
Eric Leijonmarck
f4bed21cee
remove /upgradeall apiendpoint (#46638) 2022-03-16 15:33:13 +01:00
Karl Persson
d27ff42376
Access control: Move data source actions and scopes to datasource package (#46594)
* Add permission actions and id scope

* Remove scope and actions variable prefix

* Move page evaluators and rename them
2022-03-16 15:11:03 +01:00
Yuriy Tseretyan
ea815d640f
Search Service to support search for folders available for alerting (#46483)
* support new query type "alert-folder"
* move action calculation to the constructor of the filter
* update filter to support query type `dash-folder-alerting` and empty dashboard actions
* require folders:read to access alert rules
2022-03-16 14:07:04 +00:00
Karl Persson
7192b7caee
Access control: Move licensing actions to licensing package (#46588)
* Move licensing actions to licensing package
2022-03-16 14:37:19 +01:00
Yuriy Tseretyan
c42d2e6f5d
Alerting: Add support for fine-grained access to alerting APIs (#46561) 2022-03-16 09:36:58 -04:00
Karl Persson
8261e781d5
Access control: Delete user permissions when a user is deleted (#46021)
* Remove access control related to user on deletion
2022-03-16 10:43:44 +01:00
Yuriy Tseretyan
468def0c00
Alerting: fixed roles for fine-grained access control (#46553)
* move alerting actions to accesscontrol to avoid cycledeps
* define new actions and fixed roles for alerting
* add folder permission to alert reader role
2022-03-15 14:30:32 -04:00
Alexander Weaver
92716cb602
Alerting: Create abstraction for launching transactions and refactor existing transaction management to use it (#46216)
* Remove InTransaction from RuleStore and make it its own interface

* Ensure that ctx-based is clear from name

* Resolve merge conflicts

* Refactor tests to work in terms of the introduced abstraction rather than concrete dbstore
2022-03-15 11:48:42 -05:00
Jguer
04267a66ec
Service Accounts: Refactor login service to use sqlstore methods (#46585)
* refactor login service to use sqlstore methods

* trailing newline
2022-03-15 16:57:21 +01:00
Yuriy Tseretyan
e62e9904ee
Folder UID scope resolver (#46426) 2022-03-15 15:37:16 +01:00
Leonard Gram
f46038ed3a
Search: sort results correctly when using postgres (#46466)
* Search: sort results correctly when using postgres

postgresql puts nulls first while both mysql and sqlite puts them last

* linting
2022-03-15 15:08:40 +01:00
Ieva
510c69ec91
Access control: allow hiding roles (#46358)
* allow hiding roles

* extend docs

* docs feedback

* extend provisioning docs

* formatting

Co-authored-by: Leonard Gram <leo@xlson.com>
2022-03-15 13:17:45 +00:00
Gabriel MABILLE
75935c75c1
ServiceAccounts: Fix role update (#46568)
* ServiceAccounts: Fix role update

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

* Fix patch missing metadata

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

* Fix patch missing metadata

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

Co-authored-by: Jguer <joao.guerreiro@grafana.com>
2022-03-15 10:48:10 +01:00
Jean-Philippe Quéméner
e135b8531a
Alerting: refactor receiver validation to be reusable (#46103) 2022-03-15 00:27:10 +01:00
Sarah Zinger
275f33cf37
Azure Monitor: Add feature gating for new MetricsQueryEditor with resource picker (#46124)
* Azure Monitor: Use feature toggle for dev of new UI for Metrics Queries.

* Fixes after CR
2022-03-14 15:07:45 -04:00
Jguer
ef9fe26886
Service accounts: Split user and service account database (#46442)
* ServiceAccounts: remove unused endpoint

* ServiceAccounts: remove usage of getOrgUsers from service accounts

* use dialect for boolean str true in delete

* return service account results directly

* Move Service Account Deletions to sa package

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

* Move service account methods to service accounts

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

* Service accounts should not interfere with users

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

* filter service accounts in user services

* mispell fix

* fix overextended lines

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

* fix variable

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
Co-authored-by: gamab <gabi.mabs@gmail.com>
2022-03-14 18:24:07 +01:00
Gabriel MABILLE
74b441536d
ServiceAccount: fix writer role version (#46540) 2022-03-14 17:35:39 +01:00
Karl Persson
544b6ab736
Access control: Add logs to access control dashboard guardian (#46534)
* Add logs to access control dashboard guardian

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2022-03-14 17:12:09 +01:00
Karl Persson
8688073564
Access control: Support filter on several actions (#46524)
* Add support for several actions when creating a acccess control sql
filter
2022-03-14 17:11:21 +01:00
Yuriy Tseretyan
9465eb1b3a
Folder store (#46431)
* create FolderStore
* update usages to provide context
* implement methods to get folder by ID and UID
* update folder service to use store methods
2022-03-14 11:21:42 -04:00
gotjosh
a75d4fcbd8
Alerting: Display query from grafana-managed alert rules on /api/v1/rules (#45969)
* Aleting: Extract query from alerting rule model for api/v1/rules

* more changes and fixtures

* appease the linter
2022-03-14 10:39:20 +00:00
Artur Wierzbicki
ed924b3d0c
Storage: list filtering and root folder support (#46453)
* git the things: FS api internal changes

* remove filestorage/service.go

* remove filestore flag

* remove dummy fs

* readd fileblob import
2022-03-11 22:08:19 +04:00
Gabriel MABILLE
bd918927b4
Accesscontrol: fix data source name resolver and add uid name resolver (#46409)
* Fix data source scope resolver

* Adding ds UID scope resolver

* Register UID resolver

* use package full name

* even if it cannot be empty as of now and is also checked by store, better safe than sorry
2022-03-11 08:50:04 +01:00
Marcus Efraimsson
6c7d326499
Plugins: Refactor GetPluginDashboards/LoadPluginDashboard (#46316)
Refactors GetPluginDashboards/LoadPluginDashboard by moving database 
interaction from plugin management to the plugindashboards service.

Fixes #44553

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
2022-03-10 18:38:04 +01:00
Yuriy Tseretyan
d076cabb60
Folder name scope resolver (#46380)
* move dashboard store mock to parent package to avoid cycle of dependencies
* add scope resolver for folders that resolves names to id
2022-03-10 12:19:50 -05:00
Karl Persson
52decfaebc
Access control: Move call to create default permissions into folder and dashboard service (#46186)
* Move call to create permissions into folder service

* Inject cfg, feature toggles and permissions services into dashboard
service

* Move logic to set default permissions on create dashboard from api to
service

* Move call to set default permissions on import dashboard to dashboard
service

* Set permissions for provisioned dashboard and folders in service
2022-03-10 12:58:18 +01:00
gotjosh
8d4a0a0396
Alerting: Include annotations in prometheus Alert response. (#45970)
* Alerting: Include annotations in prometheus Alert response.

* add tests

* re-order depedencies
2022-03-09 18:20:29 +00:00
Yuriy Tseretyan
314be36a7c
Move datasource scopes and actions to access control package (#46334)
* create scope provider
* move datasource actions and scopes to datasource package + add provider
* change usages to use datasource scopes and update data source name resolver to use provider
* move folder permissions to dashboard package and update usages
2022-03-09 11:57:50 -05:00
Yuriy Tseretyan
f7894db99c
Alerting: declare authorization actions, scopes and roles for fine-grained access (#45748)
* add actions, roles and route mapping for rule permission
* add instance\notification actions
* do not declare alerting roles if no feature flag is set (temporary)
2022-03-08 09:22:16 -05:00
J Guerreiro
874ac9180b
Service Accounts: Add enabled/disabled status to list (#46259)
* ServiceAccounts: improve where condition

* ServiceAccounts: Add Enabled/Disabled status to list
2022-03-08 14:10:16 +01:00
Karl Persson
1f3f4ebe21
Support permission filter in access control search filter (#46317) 2022-03-08 12:46:49 +01:00
J Guerreiro
2aeae69a16
Service Accounts: Display name to ID (#46258)
* ServiceAccounts: modernize SA creation interface

* ServiceAccounts: improve service account ID generation

* ServiceAccounts: remove unused method

* ServiceAccounts: Make SA ID display name dependent

* ServiceAccounts: Add tests for Service Account creation

* trim trailing whitespace

* Update pkg/services/serviceaccounts/api/api.go

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

* Update pkg/services/serviceaccounts/api/api.go

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2022-03-08 12:07:58 +01:00
Jeff Levin
5d2f34d8e2
ValidatedQueries: start of validated queries API (#44731)
* adds an api endpoint for use with public dashboards that validates orgId, dashboard, and panel when running a query. This feature is in ALPHA and should not be enabled yet. Testing is based on new mock sqlstore.

Co-authored-by: Jesse Weaver <jesse.weaver@grafana.com>
Co-authored-by: Leandro Deveikis <leandro.deveikis@gmail.com>
2022-03-07 09:33:01 -09:00
J Guerreiro
c6cae8411a
APIKeys: add API key migration to ensure fk is null (#46285) 2022-03-07 15:58:20 +01:00
Karl Persson
0debf33c76
Access control: Always append all permissions to role admin in oss (#46282)
* Always append all permissions to built in role admin in oss
2022-03-07 13:28:39 +01:00
Ivana Huckova
6e96506c23
Query history: Add search functionality (#45932)
* Query history: Add search functionality

* Add more tests

* Add documentation

* Fix spell errors

* Update docs

* Update docs

* Fix lint error

* Update docs/sources/http_api/query_history.md

Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>

* Document limit

* Run tests with postgres and mysql

* Use CASE insted of IIF

* Use BooleanStr instead of 1

* Change LIKE to LikeStr()

* Return back integration tests

* Update SQL to use Bool() everywhere

* Create new tests for sorting

* Update docs/sources/http_api/query_history.md

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

* Update docs/sources/http_api/query_history.md

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

* Update docs/sources/http_api/query_history.md

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

* Update docs/sources/http_api/query_history.md

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

* Update docs/sources/http_api/query_history.md

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

* Add page, count and limit to results

* Remove newline

* Update documentation

* Update docs

Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
2022-03-07 12:28:04 +01:00
Yuriy Tseretyan
288e8eeb15
Alerting: Do not update rule in database if it was not changed (#45980)
* do not include update if no diff
* refactor calculate changes to include diff (and log)

Co-authored-by: George Robinson <george.robinson@grafana.com>
2022-03-04 16:16:33 -05:00
J Guerreiro
7f1e8cee2b
APIKeys: Add AC controls for legacy API keys (#46255)
* APIKeys: Add AC controls for legacy API keys

* pluralize actions
2022-03-04 19:01:03 +01:00
Will Browne
6a8cbd8663
Plugins: Plugin settings refactor (#46246)
* remove bus and direct use of sqlStore

* add decryption to interface

* return nil

* rename field

* re-order fields

* rename file
2022-03-04 17:09:50 +01:00
Eric Leijonmarck
3d168eb34b
Searchable service accounts (#45844)
* WIP

* draft of WIP

* feat: search and filtering works 🌈

* Update pkg/models/org_user.go

* Apply suggestions from code review

* refactor: remove unsed function

* refactor: formatting

* Apply suggestions from code review

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

* WIP

* comment

* Update public/app/features/serviceaccounts/ServiceAccountsListPage.tsx

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

* review comments

* wip

* working search and initial load of service accounts

* number of tokens working

* removed api call

* Apply suggestions from code review

* added accescontrol param

* accesscontrol prefix corrected

Co-authored-by: J Guerreiro <joao.guerreiro@grafana.com>
Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
2022-03-04 12:04:07 +01:00
Sergey Kostrukov
1dca39fb91
Auth Proxy: encoding of non-ASCII headers (#44797)
* Decode auth proxy headers using URL encoding

* Header encoding configuration via settings file

* Rename configuration setting to headers_encoded

* Quoted-printable encoding

* Tests for AuthProxy

* Fix encoding name

* Remove authproxy init
2022-03-04 04:58:27 -05:00
Gilles De Mey
a9b1a964b0
Alerting: adds support for federated rules (#46037) 2022-03-04 10:16:13 +01:00
Karl Persson
8cea8fdaea
Access Control: Filter out hidden permissions in access control dashboard guardian (#46177)
* Implement GetHiddenACL to handle legacy api correctly
2022-03-03 18:29:39 +01:00
Karl Persson
4982ca3b1d
Access control: Use access control for dashboard and folder (#44702)
* Add actions and scopes

* add resource service for dashboard and folder

* Add dashboard guardian with fgac permission evaluation

* Add CanDelete function to guardian interface

* Add CanDelete property to folder and dashboard dto and set values

* change to correct function name

* Add accesscontrol to folder endpoints

* add access control to dashboard endpoints

* check access for nav links

* Add fixed roles for dashboard and folders

* use correct package

* add hack to override guardian Constructor if accesscontrol is enabled

* Add services

* Add function to handle api backward compatability

* Add permissionServices to HttpServer

* Set permission when new dashboard is created

* Add default permission when creating new dashboard

* Set default permission when creating folder and dashboard

* Add access control filter for dashboard search

* Add to accept list

* Add accesscontrol to dashboardimport

* Disable access control in tests

* Add check to see if user is allow to create a dashboard

* Use SetPermissions

* Use function to set several permissions at once

* remove permissions for folder and dashboard on delete

* update required permission

* set permission for provisioning

* Add CanCreate to dashboard guardian and set correct permisisons for
provisioning

* Dont set admin on folder / dashboard creation

* Add dashboard and folder permission migrations

* Add tests for CanCreate

* Add roles and update descriptions

* Solve uid to id for dashboard and folder permissions

* Add folder and dashboard actions to permission filter

* Handle viewer_can_edit flag

* set folder and dashboard permissions services

* Add dashboard permissions when importing a new dashboard

* Set access control permissions on provisioning

* Pass feature flags and only set permissions if access control is enabled

* only add default permissions for folders and dashboards without folders

* Batch create permissions in migrations


* Remove `dashboards:edit` action

* Remove unused function from interface

* Update pkg/services/guardian/accesscontrol_guardian_test.go

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2022-03-03 15:05:47 +01:00
idafurjes
e7ea3be4bc
Resolve merge conflict lint error (#46162) 2022-03-03 08:13:26 -05:00
Selene
87d3c06fef
Fix: Add missing store in test rule (#46151) 2022-03-03 12:00:33 +01:00
idafurjes
fa7323e6d5
Provisioning: Fix plugin provisioning storing SecureJsonData (#46149)
* Provisioning: Fix plugin provisioning storing SecureJsonData

* Fix tests and rename service to pluginSettings
2022-03-03 11:57:33 +01:00
Will Browne
b54b438a24
Plugins: Refactor plugin settings service (#45967)
* tests passing

* rename and rejig

* move interface to package and rename to Store

* new package

* add import alias
2022-03-03 11:39:15 +01:00
Artur Wierzbicki
a8b90d9a25
FileStore: add basic file storage API (#46051)
* #45498: fs API alpha

* #45498: remove grafanaDS changes for filestorage.go

* #45498: fix lint

* #45498: fix lint

* #45498: remove db file storage migration

* #45498: linting

* #45498: linting

* #45498: linting

* #45498: fix imports

* #45498: add comment

* remove StorageName abstractions

* FileStore: add dummy implementation (#46071)

* #45498: bring back grafanaDs changes, add dummy filestorage

* #45498: rename grafanaDs to public

* #45498: modify join

* #45498: review fix

* #45498:  unnecessary leading newline (whitespace) IMPORTANT FIX

* #45498: fix belongsToStorage

* #45498: fix removeStoragePrefix so that it works with abs paths

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2022-03-03 10:53:26 +04:00
Yuriy Tseretyan
016d9e14ed
Add missing option "OK" for Error state (#45262)
* Add missing OK option to models
* add ok to legacy legacy UI does not support it but it is possible to do so via provisioning.
* use enums in migration so linter would catch missing cases
2022-03-02 19:07:55 -05:00
Konrad Lalik
aeec087065
Alerting: Fix silence url in notifications (#46031)
* Update silence url generation

* Update tests

* Update test to the new silence params format

* Fix tests
2022-03-02 13:06:35 +01:00