Commit Graph

372 Commits

Author SHA1 Message Date
Karl Persson
1315c67c8b
Team/User: UID migrations (#82298)
* Add user uid migration to run on every startup to protect against empty values in a upgrade downgrade scenario

* Add team uid migration to run on every startup to protect against empty values in a upgrade downgrade scenario

* Run team uid migration
2024-02-12 14:48:29 +01:00
Dan Cech
790e1feb93
Chore: Update test database initialization (#81673)
* streamline initialization of test databases, support on-disk sqlite test db

* clean up test databases

* introduce testsuite helper

* use testsuite everywhere we use a test db

* update documentation

* improve error handling

* disable entity integration test until we can figure out locking error
2024-02-09 09:35:39 -05:00
Jo
6ac0bc5ecf
Seeder: Add missing methods to Registrations (#81961)
* add slice copy method

* fix slice copy
2024-02-08 09:54:17 +01:00
William Wernert
2ab7d3c725
Alerting: Receivers API (read only endpoints) (#81751)
* Add single receiver method

* Add receiver permissions

* Add single/multi GET endpoints for receivers

* Remove stable tag from time intervals

See end of PR description here: https://github.com/grafana/grafana/pull/81672
2024-02-05 20:12:15 +02:00
Jo
7852ea012d
Access: Remove split scopes feature toggle (#81874)
* remove split scopes FT

* Revert "remove split scopes FT"

This reverts commit 349fb081d3.

* make toggle deprecated instead

* fix gen
2024-02-05 17:00:19 +01:00
Gabriel MABILLE
4a1e8f3d98
RBAC: Reject plugin registrations without a name (#81719)
* RBAC: Reject plugin registrations without a name

* Lint'
2024-02-02 11:12:00 +01:00
Yuri Tseretyan
d1073deefd
Alerting: Time intervals API (read only endpoints) (#81672)
* declare new API and models GettableTimeIntervals, PostableTimeIntervals
* add new actions alert.notifications.time-intervals:read and alert.notifications.time-intervals:write.
* update existing alerting roles with the read action. Add to all alerting roles.
* add integration tests
2024-02-01 15:17:13 -05:00
Gabriel MABILLE
3df0611f81
RBAC: Fix authorize in org (#81552)
* RBAC: Fix authorize in org

* Implement option 2

* Fix typo

* Fix alerting test

* Add test to cover the not member case
2024-02-01 12:37:01 +01:00
Gabriel MABILLE
08f305797f
RBAC: Add metric to count search user permissions cache hits (#81451) 2024-01-30 10:37:47 +01:00
Ieva
048d1e7c86
RBAC: Annotation permission migration (#78899)
* add annotation permissions to dashboard managed role and add migrations for annotation permissions

* fix a bug with conditional access level definitions

* add tests

* Update pkg/services/sqlstore/migrations/accesscontrol/dashboard_permissions.go

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

* apply feedback

* add batching, fix tests and a typo

* add one more test

* undo unneeded change

* undo unwanted change

* only check the default basic permissions for non-OSS instances

* account for all wildcards and simplify the check a bit

* error handling and extra conditionals to avoid test failures

* fix a bug with admin permissions not appearing for folders

* fix the OSS check

---------

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2024-01-26 17:17:29 +00:00
Gabriel MABILLE
7512b1a519
RBAC: Search fix userID filter (#81337) 2024-01-26 12:23:48 +02:00
Gabriel MABILLE
19194ea122
RBAC: Remove redundant search endpoint (#81331) 2024-01-26 11:11:41 +02:00
Gabriel MABILLE
722b78f3e0
RBAC: Add userLogin filter to the permission search endpoint (#81137)
* RBAC: Search add user login filter

* Switch to a userService resolving instead

* Remove unused error

* Fallback to use the cache

* account for userID filter

* Account for the error

* snake case

* Add test cases

* Add api tests

* Fix return on error

* Re-order imports
2024-01-26 09:43:16 +01:00
Ieva
dc9e590b7b
RBAC: Return the underlying error instead of internal server or bad request for managed permission endpoints (#80974)
* return not found instead of an internal server error when listing/updating permissions

* openapi gen
2024-01-25 16:24:52 +00:00
Misi
4577e61ee7
Auth: Improve /admin/authentication permission checks and include new SSO pages (#81183)
* Move evalAuthSettings to ssoutils

* Improve permission check for auth page
2024-01-25 11:13:24 +01:00
idafurjes
7e5544ab21
Add MFolderIDsServiceCount to count folderIDs in services pkg (#81237) 2024-01-25 11:10:35 +01:00
Marcus Efraimsson
6768c6c059
Chore: Remove public vars in setting package (#81018)
Removes the public variable setting.SecretKey plus some other ones. 
Introduces some new functions for creating setting.Cfg.
2024-01-23 12:36:22 +01:00
Alexander Zobnin
08082104e1
Access control: Add permissions cache hit/miss metrics (#80883)
* Access control: Add permissions cache hit/miss metrics

* Add metrics to OSS

* Fix imports
2024-01-19 13:47:58 +01:00
Gabriel MABILLE
dce9d1e87c
RBAC: Search endpoint support wildcards (#80383)
* RBAC: Search endpoint support wildcards

* Allow wildcard filter with RAM permissions as well
2024-01-17 17:07:47 +01:00
Karl Persson
7b58f71b33
AuthN: Add auth hook that can sync grafana cloud role to rbac cloud role (#80416)
* AuthnSync: Rename files and structures

* AuthnSync: register rbac cloud role sync if feature toggle is enabled

* RBAC: Add new sync function to service interface

* RBAC: add common prefix and role names for cloud fixed roles

* AuthnSync+RBAC: implement rbac cloud role sync

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2024-01-17 10:55:47 +01:00
Ieva
def1b05a93
RBAC: Clean up data source permissions after data source deletion (#80654)
* clean up data source permissions after data source deletion

* remove a comment
2024-01-17 09:49:33 +00:00
Gabriel MABILLE
48ff532ca8
RBAC: Add histogram metric on search endpoint (#80553)
RBAC: Add histogram on search endpoint
2024-01-15 17:56:01 +01:00
Gabriel MABILLE
c9ac069076
RBAC: Add origin column to seed_assignment (#80326)
* RBAC: Add origin column to seed_assignment

* Add OnCall permission migration
2024-01-11 18:43:43 +01:00
Ryan McKinley
1caaa56de0
FeatureFlags: Use interface rather than manager (#80000) 2024-01-09 10:38:06 -08:00
Julien Duchesne
c7f515b9b2
fix(swagger): POST -> GET method for two access control endpoints (#80082)
Missed those here: https://github.com/grafana/grafana/pull/80053
2024-01-05 09:40:08 -05:00
Julien Duchesne
5e74c19628
fix(swagger): Add new access control endpoints (#80053)
There were a few errors that prevented these endpoints (which are the most up-to-date ones) from being present in the openapi spec:
- The `enterprise` tag excluded the endpoints from being generated
- `okRespoonse` typo
- Invalid templating on the parameters
- Missing parameter structs
2024-01-05 08:12:01 -05:00
Jo
3bcde852ac
AccessControl: Add safety valve truncation for long user defined scopes (#79854)
* fix migrator bootloop by invalidating permissions

* add test for scope truncation

* lint

* fix max size scope
2023-12-27 17:31:26 +01:00
Aaron Godin
eb490193b9
[IAM] - Add swagger docs for resource permissions API (#79525)
* IAM: Apply swagger-go comments for generating docs on resource permissions endpoints

* Update pkg/services/accesscontrol/resourcepermissions/api.go

Clarifies swagger note on assigning to service accounts

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

---------

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2023-12-18 16:47:17 -06:00
Julien Duchesne
b232c64d9a
accesscontrol swagger: Add global field to RoleDTO type (#79351)
* `accesscontrol` swagger: Add `global` field to `RoleDTO` type
The field is currently added in the MarshalJSON function so it isn't reflected in the spec
This PR sets the "static" version of the RoleDTO, that has the global field, as the swagger model

* Revert the marshalling logic
2023-12-12 08:04:25 -05:00
Alexander Zobnin
959ebf82da
Folders: Show dashboards and folders with directly assigned permissions in "Shared" folder (#78465)
* Folders: Show folders user has access to at the root level

* Refactor

* Refactor

* Hide parent folders user has no access to

* Skip expensive computation if possible

* Fix tests

* Fix potential nil access

* Fix duplicated folders

* Fix linter error

* Fix querying folders if no managed permissions set

* Update benchmark

* Add special shared with me folder and fetch available non-root folders on demand

* Fix parents query

* Improve db query for folders

* Reset benchmark changes

* Fix permissions for shared with me folder

* Simplify dedup

* Add option to include shared folder permission to user's permissions

* Fix nil UID

* Remove duplicated folders from shared list

* Folders: Fix fetching empty folder

* Nested folders: Show dashboards with directly assigned permissions

* Fix slow dashboards fetch

* Refactor

* Fix cycle dependencies

* Move shared folder to models

* Fix shared folder links

* Refactor

* Use feature flag for permissions

* Use feature flag

* Review comments

* Expose shared folder UID through frontend settings

* Add frontend type for sharedWithMeFolderUID option

* Refactor: apply review suggestions

* Fix parent uid for shared folder

* Fix listing shared dashboards for users with access to all folders

* Prevent creating folder with "shared" UID

* Add tests for shared folders

* Add test for shared dashboards

* Fix linter

* Add metrics for shared with me folder

* Add metrics for shared with me dashboards

* Fix tests

* Tests: add metrics as a dependency

* Fix access control metadata for shared with me folder

* Use constant for shared with me

* Optimize parent folders access check, fetch all folders in one query.

* Use labels for metrics
2023-12-05 16:13:31 +01:00
Karl Persson
0f0249abea
RBAC: Fix filter so that check for access on service account is correct (#78907)
Fix filter so that check for access on service account is in correct place
2023-11-30 17:32:04 +02:00
Gabriel MABILLE
72d32eed27
ExtSvcAuth: Assign roles locally (#78669)
* ExtSvcAuth: Assign roles locally

* Fix test

* HandlePluginStateChanged in the OrgID

* Remove Global from command

* Use AssignmentOrgID instead of OrgID

* Remove unecessary test case
2023-11-29 12:12:30 +01:00
Karl Persson
1c270b1dc2
RBAC: Adjust filter for acl list to check for permissions on service accounts (#78681)
Adjust filter to check for permissions on service accounts
2023-11-27 13:37:31 +01:00
Gabriel MABILLE
91a5c3803c
RBAC: GrafanaAdmin users are admins of the Global Organization (#78559) 2023-11-23 12:17:28 +01:00
Jo
0de66a8099
Authz: Remove use of SignedInUser copy for permission evaluation (#78448)
* remove use of SignedInUserCopies

* add extra safety to not cross assign permissions

unwind circular dependency

dashboardacl->dashboardaccess

fix missing import

* correctly set teams for permissions

* fix missing inits

* nit: check err

* exit early for api keys
2023-11-22 14:20:22 +01:00
Gabriel MABILLE
b6b86bb0b3
RBAC: Check plugins:install globally (#78438)
* RBAC: Check plugins:install globally

* Add disclamer to the RBACSingleOrganization config option
2023-11-21 15:09:43 +01:00
Misi
7ae0ff1309
RBAC: Add OAuth provider scopes separately to fixed:authentication.config:writer (#78202)
Add OAuth provider setting scopes to fixed:authentication writer

* Change SSO Settings api scopes

* Remove unused RBAC Action
2023-11-16 09:15:51 +01:00
Kat Yang
3a2e96b0db
Chore: Deprecate FolderID from Dashboard (#77823)
* Chore: Deprecate FolderID from Dashboard

* chore: add two missing nolint comments
2023-11-15 10:28:50 -05:00
Misi
19a7cd88b0
Auth: Add SAML scopes to fixed:authentication.config:writer (#78147)
Add SAML scopes back to fixed authenticationConfigWriterRole
2023-11-14 23:02:52 +02:00
Ryan McKinley
f69fd3726b
FeatureToggles: Add context and and an explicit global check (#78081) 2023-11-14 12:50:27 -08:00
Ryan McKinley
3509a5abb9
FeatureFlags: Cleanup usage of cfg.IsFeatureToggleEnabled (#78014) 2023-11-13 07:55:15 -08:00
Misi
5285e9503b
Auth: SSO settings foundations (#77724)
* inital changes, db migration

* changes

* Implement basic GetAll, Delete

* Add first batch of tests

* Add more tests

* Add service tests for GetForProvider, List

* Update http_server.go + wire.go

* Lint + update fixed role

* Update CODEOWNERS

* Change API init

* Change roles, rename

* Review with @kalleep

* Revert a mistakenly changed part

* Updates based on @dmihai 's feedback

---------

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
2023-11-08 10:50:01 +01:00
Ieva
159bb3c032
RBAC: Allow scoping access to root level dashboards (#76987)
* correctly check permissions to list dashboards on the root

* correctly display the access inherited from general folder for dashboards

* Update pkg/services/sqlstore/permissions/dashboard.go

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

* Update dashboard_filter_no_subquery.go

---------

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2023-10-24 11:55:38 +03:00
Gabriel MABILLE
797a3c57af
Plugins: Automatic service account (and token) setup (#76473)
* Update cue to have an AuthProvider entry

* Cable the new auth provider

* Add feature flag check to the accesscontrol service

* Fix test

* Change the structure of externalServiceRegistration (#76673)
2023-10-17 16:21:23 +02:00
Karl Persson
ae5e03034b
RBAC: generated prefixed uids for external service role (#76601)
* Replace FixedRoleUID function with a common function to generate these prefixes

* Use common function to generate prefixed uid for external service accounts

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

---------

Co-authored-by: Gabriel MABILLE <gabriel.mabille@grafana.com>
2023-10-16 13:12:16 +02:00
Jo
48ef88aed7
Access: Fetch fresh permissions for target GlobalOrgID in AuthorizeInOrgMiddleware (#76569)
fetch fresh permissions for global in AuthorizeInOrgMiddleware

Update pkg/services/accesscontrol/authorize_in_org_test.go

do not load viewer permissions in global ID
2023-10-13 21:01:47 +03:00
kay delaney
a12cb8cbf3
LibraryPanels: Add RBAC support (#73475) 2023-10-12 00:30:50 +01:00
Gabriel MABILLE
9dd38de5c1
RBAC: Make fixed role UIDs deterministic (#76239)
* Add fixed role UID

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

* Use base64 url encoding

---------

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
2023-10-10 16:29:31 +02:00
Jo
4474f19836
Service Accounts: Enable adding folder, dashboard and data source permissions to service accounts (#76133)
* Add SAs to Datasource permissions

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

* add SAs to dashboards/folders managed permissions

* Update public/app/core/components/AccessControl/Permissions.tsx

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

* regenerate i18n

* add doc

---------

Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
2023-10-06 17:48:13 +02:00
Karl Persson
7a38090bc0
AuthN: Fix namespaces for anonymous and render (#75661)
* AuthN: remove IsAnonymous from identity struct and set correct namespace for anonymous and render

* Don't parse user id for render namespace
2023-09-29 09:10:33 +02:00