160 Commits

Author SHA1 Message Date
d7a4f497bc Folders: Correctly resolve nested folder breadcrumbs (#106344)
correctly use UID scope instead of ID based scope
2025-06-05 10:02:07 +01:00
feaaf96269 RBAC: Remove folder guardians part 2 (#104645)
* replace usage of folder guardians with access control evaluators

* remove NewByFolderUID guardian

* bring up to date

* fix test

* more test fixes, and don't fetch the folder before evaluating lib element access

* change what error is returned

* fix alerting test

* try to fix linter errors

* replace the use of newByFolder guardian with direct access control evaluator checks

* remove newByFolder guardian

* remove unintentional changes

* remove unintentional changes

* undo unwanted change
2025-05-17 00:25:07 +03:00
e385237daf Access control: Make sure that user permission cache is cleared after new dashboard and folder creation (#104193)
* make sure that user permission cache is cleared after new dashboard and folder creation

* more test fixes

* Update pkg/services/dashboards/service/dashboard_service.go

* check identity type in SetDefaultPermissionsAfterCreate, set default permissions for service accounts

* set SA permissions for folders as well

* fix tests
2025-04-24 16:02:39 +03:00
757be6365a CI: Bump golangci-lint to 2.0.2 (#103572) 2025-04-10 14:42:23 +02:00
d8c5c2d3b8 K8s: Folders: Modify GetChildren to return only Folder References (#103072)
* Return FolderReference instead of Folder on GetChildren

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

---------

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
2025-04-02 01:30:17 -03:00
b67b9e3c5e K8s: Folders: Reduce db calls with /api/folders (#103058) 2025-03-28 18:13:08 -05:00
927f7befd6 Unistore: Create default permissions through Folder APIServer (#101420)
* Unistore: Declare a new storage to set default folder permissions

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Remove the setting of default permissions from folder legacy storage

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Disable setting of folder permissions when Api Server is enabled

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Reverts grafana/grafana#100019

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Add unit test

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* check error on unit test

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Add unit test

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Remove unused fields

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Add unit tests for folder_storage

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Remove duplicated import

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Fix unit test

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

---------

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
2025-03-11 11:33:08 +00:00
dc2defd84f K8s/Annotations: Use manager/source annotations rather than repo (#101313)
Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>
2025-03-05 08:54:20 +02:00
745a25ad0a Folders API: Return orgID in response (#99724) 2025-01-28 23:13:26 -03:00
a5c14db051 Folders: Convert between unstructured and legacy (#99504) 2025-01-27 17:37:28 +01:00
a037c6f344 K8s/Folders: Remove kubernetesFolders flag and full path metadata (#99256)
* remove full path

* remove more

* remove KubernetesFolders tests

* remove feature toggles

* remove feature toggles

* skip permissions test

* skip permissions test

---------

Co-authored-by: Jack Baldry <jack.baldry@grafana.com>
2025-01-23 17:25:03 +03:00
680e6bc1f8 Authlib: Use types package rather than claims (#99243) 2025-01-21 12:06:55 +03:00
766d645d82 Filewalkwithme/unistore refactor folder service to hit folder apiserver (#98409)
Refactor folder service to use Unified Storage

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

---------

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>
2025-01-13 18:15:35 -03:00
bdb4725768 UserDisplay: Handle both service accounts and user names when resolving "createdBy" (#98719)
* Handle both user and service accounts when resolving identity name for dashboards and folders

Co-authored-by: Misi <mgyongyosi@users.noreply.github.com>
2025-01-10 10:06:59 +01:00
937e8dea2d Folder/parent subresource (#98392)
* Expose get folder parents endpoint

* Add tests
2025-01-03 10:43:56 +01:00
d2639f6080 Ensure all internal Services are using FolderService and not FolderStore (#98370)
* Ensure all internal Services are using FolderService and not FolderStore

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

---------

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
2024-12-30 13:48:35 -03:00
df36e77cd3 [Folders] Put move and counts behid a feature flag (#98317)
* Put move and counts behid a feature flag

* Gen toggles

* Generate feature flag

* Make feature name more explicit

* Remove unused code

* Update toggle  name
2024-12-27 18:10:44 +01:00
fec5c0ec19 Make sure annotations are kept when updating a folder (#98321)
* Make sure annotations are kept when updating a folder

* Remove pointer

* Mock get on update tests
2024-12-27 13:51:10 +01:00
f5d44ff51d Folders move (#98100) 2024-12-19 09:59:14 +01:00
2e08092a34 UniStore: Get Folder Handler return Root Folder (general) (#98127)
Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
2024-12-18 22:31:55 -03:00
62c1735a61 Implement k8s count handler (#97955)
* Implement k8s count handler

* Fix endpoint

* Fix type converstions

* Add tests for foldercounts

* Add more tests

* Only use sql-fallback if no values in unistore

* Update gomod

* Fix test

* Update pkg/api/folder_test.go

Co-authored-by: Bruno Abrantes <bruno.abrantes@grafana.com>

* Go.mod

---------

Co-authored-by: Bruno Abrantes <bruno.abrantes@grafana.com>
2024-12-16 14:08:29 +01:00
7fd8877439 Unistore: Update Folders Endpoint (#97317)
* Add route for update folders via apiserver

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

---------

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
2024-12-03 15:33:01 -03:00
6d04023aa6 K8s/Folders: Improve k8s client implementation of get (#96434)
* Enable getting folders with kubernetes client
* Add TestIntegrationFolderGetPermissions
* Set full path as part of legacy get
* Replace implementation for setting fullpath
* Add folder get test
* Escape forward slash in parent titles
* Replace test for access control metadata
* Add test case to TestIntegrationFolderGetPermissions
* Improve fetching of access control
2024-11-26 16:20:00 +02:00
2a74778776 Support delete endpoint for folders (#96573)
* Support delete endpoint for folders

* Include authorizer

* Add test for delete verb

* Add delete command to delete options

* Pass query string to context to admission

* Dont support nested folder deletion for now

* Skip test if feature flag is present

* Add test case

* Remove comment

* Only rely on the storage type config to run alerting tests

* Dont change legacy subpath

* Remove unised function

* Add test case when an editor can delete alert rules

* Lint
2024-11-22 16:51:53 +01:00
bbae396db4 Unistore: Add GetFolders endpoint backed by UnifiedStorage (#96399)
* Unistore: Add GetFolders endpoint backed by UnifiedStorage

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

---------

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
Co-authored-by: Arati R. <33031346+suntala@users.noreply.github.com>
2024-11-22 10:38:00 -03:00
2e62f75166 K8s/Folders: Allow recursive creation of DTO (#96439)
* Fix toDTO
* Remove conversion function for folder dto
* Convert toDTO to a standalone function

---------

Co-authored-by: Jean-Philippe Quéméner <JohnnyQQQQ@users.noreply.github.com>
2024-11-15 15:21:57 +01:00
Jo
90d2f4659e Users: Allow specifying user UIDs in params (#95424)
* add user ID API translation

* add uid to user frontend

* use users' UIDs in admin pages

* fix ldapSync page

* use global user search for user by UID

* remove active org filtering

* remove orgID params
2024-10-30 14:14:42 +01:00
4a13580a2f K8s/Folders: Fix folder status error message (#95464)
* Fix folder status error message
* Add test for folder creation response message
* Add TestFoldersCreateAPIEndpointK8S fixes
* Fix message returned when user has no permissions
2024-10-28 12:33:56 +01:00
f3a93a0303 K8s/Folders: Enhance k8s folder update (#95033)
* Put folder update behind feature toggle
* Set more fields when doing k8s update
* Check update in folder tests
* Uncomment remaining k8s handler methods
2024-10-21 19:08:03 +02:00
65fc7cf004 K8s/Folders: Fix mode 2 folder creation (#94796)
* Use user UID as identifier instead of ID
* Remove malformed error
2024-10-16 10:44:09 +02:00
011978e81b K8s/Folders: Remove folder service from client (#94450)
* Support getting full path of UIDs
* Use full path to set parents field
* Update get folder test
* Add folder store test for getting with full path UIDs
* Add test for parsing parent titles
* Test nested folder create payload
2024-10-10 13:22:57 +02:00
ea5cf7c51f Unified Storage /Folders: Allow Unified Storage subfolders creation (#94327)
* Add parents field to folder DTO
* Allow subfolder creation when folder flag is enabled
* Update UnstructuredToLegacyFolder
* Include parents field when creating folder
2024-10-07 16:48:56 +02:00
5a9bd1d1cf K8s/Folders: Fix folder create payload (#94273)
* Fix createdBy and updatedBy
* Fix refreshing permission cache
* Update created time
* Fix user identifier parsing
2024-10-07 13:32:25 +03:00
261be0facd UniStore: Evaluate Folder DTO attributes (#93968)
* UniStore: Evaluate Folder DTO attributes

* Handle AccessControl

* Reduce the number of parameters to newToFolderDto

* Detach Metadata helpers from HTTPServer

* Add tests

---------

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
2024-10-07 12:08:16 +02:00
f403bc57d5 K8s/Folders: Clear permissions cache on create (#94214)
* Clear user permissions cache after folder creation
* Use k8s client only for create
2024-10-04 11:26:36 +02:00
e399fe6d09 Folders: Set folder creation permission as part of legacy create (#94040)
* Add folder store to dashboard permissions
* Include folder store in annotation scope resolver
* Add folder store when initialising library elements
* Include folder store in search v2 service initialisation
* Include folder store in GetInheritedScopes
* Add folder store to folder permissions provider
* Include cfg, folder permissions in folder service
* Move setting of folder permissions for folder service create method
2024-10-01 14:03:02 +02:00
2c26053be8 K8s/Folders: Convert additional fields when creating k8s resources (#93395)
* Add separate folder registration function
* Convert to k8s resource directly after legacy create
* Use create command when creating folders
* Set additional fields when converting to k8s resource
* Add created/updated timestamps during conversion
* Refactor UnstructuredToLegacyFolderDTO
* Return errors when doing k8s conversions
2024-09-25 08:56:15 +02:00
d1d578785c Add remaining k8s endpoints for Folders (#93146)
* Add remaining Folders k8s endpoints

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

* Remove duplicated import

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

---------

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
2024-09-12 14:38:27 -03:00
b12a29a1da K8s: Implement partial folders api with k8s client (#93089)
* Add kubernetes folder feature toggle
* Add kubernetes routes for getting and creating a folder
* Add documentation for interacting with k8s folders
2024-09-10 11:22:08 +02:00
8bcd9c2594 Identity: Remove typed id (#91801)
* Refactor identity struct to store type in separate field

* Update ResolveIdentity to take string representation of typedID

* Add IsIdentityType to requester interface

* Use IsIdentityType from interface

* Remove usage of TypedID

* Remote typedID struct

* fix GetInternalID
2024-08-13 10:18:28 +02:00
21d4a4f49e Auth: use IdentityType from authlib (#91763) 2024-08-12 09:26:53 +03:00
bcfb66b416 Identity: remove GetTypedID (#91745) 2024-08-09 18:20:24 +03:00
9db3bc926e Identity: Rename "namespace" to "type" in the requester interface (#90567) 2024-07-25 12:52:14 +03:00
9bb2cf4968 RBAC: Allow omitting default permissions when a new resource is created (#90720)
* Cfg: Move rbac settings to own struct

* Cfg: Add setting to control if resource should generate managed permissions when created

* Dashboards: Check if we should generate default permissions when dashboard is created

* Folders: Check if we should generate default permissions when folder is created

* Datasource: Check if we should generate default permissions when datasource is created

* ServiceAccount: Check if we should generate default permissions when service account is created

* Cfg: Add option to specify resources for wich we should default seed

* ManagedPermissions: Move providers to their own files

* Dashboards: Default seed all possible managed permissions if configured

* Folders: Default seed all possible managed permissions if configured

* Cfg: Remove service account from list

* RBAC: Move utility function

* remove managed permission settings from the config file examples, change the setting names

* remove ini file changes from the PR

* fix setting reading

* fix linting errors

* fix tests

* fix wildcard role seeding

---------

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
Co-authored-by: jguer <me@jguer.space>
2024-07-24 19:31:26 +03:00
e9ebb6eaa4 Folders: Fix folder pagination for cloud instances with many folders (#90008)
* filter the k6 folder out in the SQL queries rather than during post processing to ensure that the correct number of results is always returned

* linting
2024-07-05 11:19:03 +01:00
99d8025829 Chore: Move identity and errutil to apimachinery module (#89116) 2024-06-13 07:11:35 +03:00
59a6a6513f Prevent moving a k6 folder (#88884)
* iam-716 - prevent a folder move operation when the folder's uid or any of its parents uids begin with k6-app

* fox folder move check and only list non-k6 folders to users

* adding tests for moving

* add a test for listing folders

* fix the other tests

* use method that adds folder parent

---------

Co-authored-by: IevaVasiljeva <ieva.vasiljeva@grafana.com>
2024-06-10 09:17:51 -05:00
1208888bb6 Folders: Allow listing folders with write permission (#83527)
* Folders: Allow listing folders with write permission

* Check for subfolder access if parent does not have

* Add test

* GetFolders: fix ordering

* Apply suggestion from code review
2024-03-15 14:05:27 +02:00
b8d8662bd9 Swagger: Re-generate the enterprise specification if enterprise is cloned (#81730)
* Swagger: Re-generate the enterprise specification if enterprise is cloned successfully

* API change to trigger the swagger CI step execution

* Swagger: Silence logs
2024-03-07 12:07:35 +02:00
96dfb385ca Grafana: Replace magic number with a constant variable in response status (#80132)
* Chore: Replace response status with const var

* Apply suggestions from code review

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

* Add net/http import

---------

Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
2024-02-27 18:39:51 +02:00