Commit Graph

2912 Commits

Author SHA1 Message Date
Sofia Papagiannaki
96cdf77995
Revert "Chore: Refactor quota service (#57586)" (#58394)
This reverts commit 326ea86a57.
2022-11-08 11:52:07 +02:00
Sofia Papagiannaki
326ea86a57
Chore: Refactor quota service (#57586)
* Chore: refactore quota service

* Apply suggestions from code review
2022-11-08 10:25:34 +02:00
Ben Sully
480277f612
CallResource: don't set Content-Type header if status is 204 (#50780)
Grafana's HTTPServer ensures that the Content-Type header is always set
in the response to a CallResource call, but when the status code is
204 No Content this shouldn't be done; the body should be empty and no
Content-Type header should be set.

We ran into this in the Grafana ML plugin where we were sending an empty
response with status 204, but the frontend client saw that the content
type was JSON and tried to parse it, resulting in an error that made it
to the JS console.
2022-11-07 17:25:49 +01:00
Gabriel MABILLE
30fae33f66
RBAC: Allow role registration for plugins (#57387)
* Picking role registration from OnCall POC branch

* Fix test

* Remove include actions from this PR

* Removing unused permission

* Adding test to DeclarePluginRoles

* Add testcase to RegisterFixed role

* Additional test case

* Adding tests to validate plugins roles

* Add test to plugin loader

* Nit.

* Scuemata validation

* Changing the design to decouple accesscontrol from plugin management

Co-authored-by: Kalle Persson <kalle.persson@grafana.com>

* Fixing tests

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

* Add missing files

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

* Remove feature toggle check from loader

* Remove feature toggleimport

* Feedback

Co-Authored-By: marefr <marcus.efraimsson@gmail.com>

* Fix test'

* Make plugins.RoleRegistry interface typed

* Remove comment question

* No need for json tags anymore

* Nit. log

* Adding the schema validation

* Remove group to take plugin Name instead

* Revert sqlstore -> db

* Nit.

* Nit. on tests

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

* Update pkg/services/accesscontrol/plugins.go

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

* Log message

Co-Authored-By: marefr <marcus.efraimsson@gmail.com>

* Log message

Co-Authored-By: marefr <marcus.efraimsson@gmail.com>

* Remove unecessary method. Update test name.

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

* Fix linting

* Update cue descriptions

* Fix test

Co-authored-by: Kalle Persson <kalle.persson@grafana.com>
Co-authored-by: Jguer <joao.guerreiro@grafana.com>
Co-authored-by: marefr <marcus.efraimsson@gmail.com>
Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
2022-11-07 11:30:45 +01:00
Will Browne
09e8cff06e
Plugins: Make "README" the default markdown request param (#58264)
* Plugins: Make README the default markdown request param

* undo devdboard changes

* fix missing prefix

* rm newline

* re-add space UFFFFF
2022-11-07 11:16:17 +01:00
Jeff Levin
6fcc5b42c0
publicdashboards: split create/update api paths (#57940)
This PR splits the create and update paths for public dashboards and includes assorted refactors toward a proper REST API. Additionally, we removed the concept of a "public dashboard config" in favor of "public dashboard" 

Co-authored-by: juanicabanas <juan.cabanas@grafana.com>
Co-authored-by: Ezequiel Victorero <ezequiel.victorero@grafana.com>
2022-11-03 11:30:12 -08:00
Carl Bergquist
06705a49e2
Instrumentation: Log plugin and datasource info for each plugin request. (#54769)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
2022-11-02 14:51:51 +01:00
Kristin Laemmert
706b301285
feat(nested folders): add CountDashboardsInFolder (#57847)
* feat(nested folders): add CountDashboardsInFolder

This commit adds a new method to the Dashboard service and stores: CountDashboardsInFolder. The command struct takes a folderUID, but the store implementation still depends on the parent folder ID. This is temporary; eventually we will replace all references to FolderIDs (associated with Dashboards) with folder UIDs.

There are some unfortunate additional test changes that were necessary after generating the service & store mocks; it looks like that hasn't been generated since the last change(s).

* more test updates
* don't forget the service test
* that didn't end up used, so bye for now
* agree to disagree with the linter
2022-11-02 09:15:50 -04:00
unknowndevQwQ
6dd3584f77
Server: Make unix socket permission configurable (#52944) 2022-11-01 15:04:01 +01:00
Ryan McKinley
6e3a6cce61
Storage: move http wrapper into its own subpackage (#57929) 2022-10-31 13:37:05 -07:00
Karl Persson
052d1426f9
Oauth: Display friendly error message when role_attribute_strict=true and no valid role found (#57818)
* Oauth: change error type to a struct that unwraps into a social error

* Oauth: Handle empty role in error and fix unwrap

* Oauth: provide more informatio in error

* Oauth: return InvalidBasicRoleError

* Oauth: Fix tests

* Login: Remove casing

* Oath: Change to warning logs
2022-10-31 09:11:31 +01:00
Andrej Ocenas
0845ac2f53
Profiling: Add Phlare and Parca datasources (#57809)
* Add phlare datasource

* Rename

* Add parca

* Add self field to parca

* Make sure phlare works with add to dashboard flow

* Add profiling category and hide behind feature flag

* Update description and logos

* Update phlare icon

* Cleanup logging

* Clean up logging

* Fix for shift+enter

* onRunQuery to set label

* Update type naming

* Fix lint

* Fix test and quality issues

Co-authored-by: Joey Tawadrous <joey.tawadrous@grafana.com>
2022-10-28 13:33:37 +02:00
Ryan McKinley
7346280316
LibraryPanels: Load library panels in the frontend rather than the backend (#50560)
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
2022-10-26 15:38:20 -07:00
Ezequiel Victorero
860380d893
PublicDashboards: refactor following naming convention for services (#57625) 2022-10-25 21:40:42 -03:00
Ezequiel Victorero
1f3d34ecda
PublicDashboards: service and store methods rename (#57463) 2022-10-21 18:25:20 -03:00
Marcus Efraimsson
6f8fcae01b
[main] Plugin fixes (#57399)
* Plugins: Remove support for V1 manifests

* Plugins: Make proxy endpoints not leak sensitive HTTP headers

* Security: Fix do not forward login cookie in outgoing requests

(cherry picked from commit 4539c33fce)

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
2022-10-21 13:54:55 +02:00
Jo
7f3536a6d2
OAuth: Fix misleading warn log related to oauth and increase logged content (#57336)
* only emit warn log when sync is not skipped. Fix warn log that had wrong recommendation

* log presence of refresh token
2022-10-20 05:50:12 -04:00
Karl Persson
764d5b9929
RBAC: Cleaup team api rbac tests (#57265)
* RBAC: Remove the access control evaluator fake

* API: Change to use access control implementation instead of mocks with
rbac disabled in tests

* Tests: Set cfg and access control defaults after applying options

* Tests: Rewrite team legacy access control tests

* Tests: Add helper function to create user with permissions

* Tests: set fake quota service as default

* Team: Add ExpectedTeamDTO and set in query result

* RBAC: Revert change

* RBAC: Add deprecation notice to mock
2022-10-20 09:11:47 +02:00
Kristin Laemmert
05709ce411
chore: remove sqlstore & mockstore dependencies from (most) packages (#57087)
* chore: add alias for InitTestDB and Session

Adds an alias for the sqlstore InitTestDB and Session, and updates tests using these to reduce dependencies on the sqlstore.Store.

* next pass of removing sqlstore imports
* last little bit
* remove mockstore where possible
2022-10-19 09:02:15 -04:00
Michael Mandrus
2a8a82e2af
PublicDashboards: Don't filter datasources from FrontendSettings in a public dashboard (#57208)
* add filter skip to avoid issues with RBAC

* update comment
2022-10-18 15:44:33 -04:00
Misi
9c954d06ab
Auth: Refresh OAuth access_token automatically using the refresh_token (#56076)
* Verify OAuth token expiration for oauth users in the ctx handler middleware

* Use refresh token to get a new access token

* Refactor oauth_token.go

* Add tests for the middleware changes

* Align other tests

* Add tests, wip

* Add more tests

* Add InvalidateOAuthTokens method

* Fix ExpiryDate update to default

* Invalidate OAuth tokens during logout

* Improve logout

* Add more comments

* Cleanup

* Fix import order

* Add error to HasOAuthEntry return values

* add dev debug logs

* Fix tests

Co-authored-by: jguer <joao.guerreiro@grafana.com>
2022-10-18 18:17:28 +02:00
Kristin Laemmert
c61b5e85b4
chore: replace sqlstore.Store with db.DB (#57010)
* chore: replace sqlstore.SQLStore with db.DB

* more post-sqlstore.SQLStore cleanup
2022-10-14 15:33:06 -04:00
Michael Mandrus
ea8549b8c2
Datasources: Support mixed datasources in a single query (#56832)
* initial cut at refactor - need to run more tests

* fix unit tests

* change newly unused function to test helper

* create unit tests for parsing query requests that cover a range of cases

* add some comments

* rename function to avoid dev confusion
2022-10-14 10:27:06 -04:00
Josh Hunt
2e16d5499e
Dashboard: Add dashboard validation warning to save drawer (#55732)
* add api route for validating a dashboard json

* add feature flag for showDashboardValidationWarnings

* tidy up

* comments and messages

* swagger specs

* fix typo

* more swagger

* tests!

* tidy test a little bit

* no more ioutil

* api will return different status code depending on validation error

* clean up

* handle 4xx errors

* remove console.log

* fix backend tests

* tidy up

* Swagger: Exclude alpha endpoints

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
2022-10-14 09:51:05 -04:00
Jeff Levin
cc27214dca
Public Dashboards: Add audit table (#54508)
This PR adds an audit table for public dashboards allowing a user to view all public dashboards on an instance of grafana. The public dashboards team is working on a proposal for adding RBAC support to the audit table for 9.3

Co-authored-by: juanicabanas <juan.cabanas@grafana.com>
2022-10-12 21:36:05 -08:00
Alex
94ed744454
Auth: Make built-in login configurable (#46978) 2022-10-12 15:34:59 +00:00
Gabriel MABILLE
10c080dad1
LDAP: Add skip_org_role_sync configuration option (#56679)
* LDAP: Add skip_org_role_sync option

* Document the new config option

* Nit on docs

* Update docs/sources/setup-grafana/configure-security/configure-authentication/ldap.md

Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>

* Docs suggestions

Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
Co-authored-by: Jguer <joao.guerreiro@grafana.com>

* Add test, Fix disabled user when no role

Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
Co-authored-by: Jguer <joao.guerreiro@grafana.com>
2022-10-12 13:33:33 +02:00
Junaid Ali
33eb4a2807
Exclude full OAuth token details from printing out on stdout (#55426)
* remove token details from printing out on stdout

* Update login_oauth.go

* address comment
2022-10-11 17:20:49 +02:00
Sofia Papagiannaki
7e24e19230
Swagger: Remove license (#56716) 2022-10-11 17:06:36 +03:00
sam boyer
5641029a4a
coremodels: Always take runtime arg for NewBase() (#56677) 2022-10-11 05:39:29 -04:00
Serge Zaitsev
53baecd71f
Chore: Move folder service into a separate package (#56591)
* Chore: move folder service interface into a separate package

* copy implementation into a standalone package

* move implementation and tests to the new folder package

* remove leftovers from wire

* add test doubles for folder service

* fix tests in library panels/elements

* fix provideservice in ngalert
2022-10-10 21:47:53 +02:00
Artur Wierzbicki
bf264d2f76
Query library: requiresDevMode dummy backend (#56466)
* query library - dummy backend

* fix tests

* dont explicitly marshall backend dataresponse

* skip integration tests

* null check for tests

* added query library to codeowners

* null check for tests

* lint
2022-10-07 11:31:45 -07:00
Joey Tawadrous
74c809f544
Plugins: Introduce new Flame graph panel (#56376)
* Flamegraph

* Updated flame graph width/height values

* Fix top table rendering issue

* Add feature toggle for flamegraph in explore

* Update tests

* Hide flamegraph from dash panel viz list if feature toggle not enabled

* Show table if no flameGraphFrames

* Add flame graph to testdata ds

* Minor improvement
2022-10-07 11:39:14 +01:00
Jeff Levin
331110bde5
refactor public dashboards middleware testing (#55706)
This PR refactors how we add the orgId to the context on a public dashboard paths. We also split out accessToken handling into its own package and rework status code for "RequiresValidAccessToken". We will be modeling all endpoints to use these status codes going forward. Additionally, it includes a scaffold for better middleware testing and refactors existing tests to table drive tests.
2022-10-06 12:35:19 -08:00
ying-jeanne
d9cc292066
Star: Add uid in the endpoint (#54340)
* add new uid endpoing for star

* add store pool into service

* fix the endpoint caller

* udpate swagger file

* Update pkg/api/stars.go

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>

* remove useless code for star dashboard

* add new uid endpoing for star

* add store pool into service

* fix the endpoint caller

* Update pkg/api/stars.go

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>

* Update pkg/api/stars.go

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>

* solve linter

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
2022-10-05 22:32:49 +02:00
idafurjes
bc7a383252
Remove org methods from sqlstore interface (#56358)
* Remove org methods from sqlstore interface

* Remove some mocks

* Fix some tests
2022-10-05 15:47:56 +02:00
idafurjes
5167c55760
Chore: Move methods from sqlstore to user store (#56305)
* Copy sqlstore methods to suer store

* Adjust ProvideService signatures in test

* Add xorm tags and tests for search

* Remove methods from sqlstore

* fix lint in tests
2022-10-05 09:34:36 +02:00
Kat Yang
7715672fb3
Chore: use org service methods (#55768)
* Chore: use org service methods

* fix tests

* fix errors

* adjust func signatures for getbyname

* 💩

* Use the same fake service to get the user in AC and in HS

* Fix middleware test

* Fix more middleware test

* Fix api tests

Co-authored-by: gamab <gabi.mabs@gmail.com>
Co-authored-by: Ida Furjesova <ida.furjesova@grafana.com>
2022-10-04 14:48:02 -04:00
Ryan McKinley
d5e2713168
Storage: Add HTTP endpoint for object store service (#56214) 2022-10-04 09:40:15 -07:00
Ryan McKinley
3b1a8d45ed
Playlist: update service so it supports both read+write (#55959) 2022-10-04 11:11:18 -04:00
idafurjes
a25516fbe3
Chore: Copy sqlstore methods to user store (#56280)
* Chore: Copy sqlstore methods to user store

* Fix xorm tag

* Add tests

* Remove unused methods from sqlstore
2022-10-04 14:14:32 +02:00
idafurjes
a863a4d95d
Chore: Copy user methods over to user store (#56000)
* Chore: Copy user methods over to user store

* Fix some tests and bugs

* Add some more tests

* Move tests to user store

* Move back the tests

* Add some tests
2022-10-04 12:17:55 +02:00
Ashley Harrison
8984507291
Navigation: show breadcrumbs correctly when on the home page (#55759)
* show breadcrumbs correctly when on the home page

* adjust breadcrumb unit tests

* update betterer

* fix backend tests

* update getSectionRoot to look at the home nav id

* remove redundant setting of home dashboard

* construct a home navmodelitem in the backend

* fix cases when the feature toggle is off

* fix unit test

* fix more unit tests

* refactor how buildBreadcrumbs works

* use HOME_NAV_ID

* move homeNav useSelector into NavToolbar

* remove unnecesary cloneDeep

* don't need locationUtil here

* restore using getUrlForPartial in DashboardPage

* special case for the editview query param

* remove commented out code

* add comment to clarify splice behaviour

* slightly cleaner syntax
2022-10-03 15:05:19 +01:00
sam boyer
9ec7b202b6
playlist: introduce coremodel schema, swap in for backend DTO types (#56048)
* Add simplest possible playlist schema

* Add @grafana(decisionNeeded) attributes

* playlistid, not playlist_id
2022-09-30 06:33:11 -04:00
ying-jeanne
2472777ce2
Chore: implement sqlx into tag service (#55908)
* add sqlx store to tag service

* add sqlx into tag service

* fix test

* change to camal cases

* change in xorm camal case
2022-09-28 08:23:40 -04:00
idafurjes
a45ef61d25
Chore: Remove GetUserByEmail and GetUserByLogin from sqlstore (#55903)
* Chore: Remove GetUserByEmail and GetUserByLogin from sqlstore
 Rename GetUserProfile to GetProfile

* Fix lint

* Skip test for mysql

* Add missing method to sqlstore mock
2022-09-28 13:18:19 +02:00
Torkel Ödegaard
e31cb93ec0
NavTree: Make it possible to configure where in nav tree plugins live (#55484)
* NewIA: Plugin nav config

* progress

* Progress

* Things are working

* Add monitoring node

* Add alerts and incidents

* added experiment with standalone page

* Refactoring by adding a type for navtree root

* First test working

* More tests

* more tests

* Progress on richer config and sorting

* Sort weight working

* Path config

* Improving logic for not including admin or cfg nodes, making it the last step so that enterprise can add admin nodes without having to worry about the section not existing

* fixed index routes

* removed file

* Fixes

* Fixing tests

* Fixing more tests and adding support for weight config

* Updates

* Remove unused fake

* More fixes

* Minor tweak

* Minor fix

* Can now control position using sortweight even when existing items have no sortweight

* Added tests for frontend standalone page logic

* more tests

* Remove unused fake and fixed lint issue

* Moving reading settings to navtree impl package

* remove nav_id setting prefix

* Remove old test file

* Fix trailing newline

* Fixed bug with adding nil node

* fixing lint issue

* remove some code we have to rethink

* move read settings to PrivideService and switch to util.SplitString
2022-09-28 08:29:35 +02:00
ying-jeanne
b96a3832d0
StoreSplit: move dashboard thumbs into thumbs service (#55800)
* move dashboard thumbs into thumbs service

* rename some variables
2022-09-27 08:46:03 -04:00
Kristin Laemmert
701f6d5436
UserService: use the UserService instead of calling sqlstore directly (#55745)
* UserService: update callers to use the UserService instead of calling sqlstore directly

There is one major change hiding in this PR. UserService.Delete originally called a number of services to delete user-related records. I moved everything except the actual call to the user table, and moved those into the API. This was done to avoid dependencies cycles; many of our services depend on the user service, so the user service itself should have as few dependencies as possible.
2022-09-27 07:58:49 -04:00
idafurjes
d8cd30d22a
Chore: Remove DeleteOrg and UpdateOrgAddress from sqlstore (#55795)
* Chore: Remove DeleteOrg and UpdateOrgAddress from sqlstore

* Remove commented out methods
2022-09-27 12:30:10 +02:00