Commit Graph

9 Commits

Author SHA1 Message Date
Ieva 7bd20b98ba
AuthZ: code and error cleanup (#111037)
* use API errors where possible

* fix test
2025-09-18 11:38:02 +01:00
Gabriel MABILLE ee34c015ce
`grafana-iam`: Fix context for identity store queries to work (#111228)
`grafana-iam`: Fix context for identity store

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2025-09-17 11:24:58 +01:00
Ieva d4399e6eda
`grafana-iam`: Implement `resourcepermission` update (#110891)
* first go at update implementation

* template tests

* SQL tests

* more tests

* set namespace for read resource permissions

* fix a bug with perms being removed right after they're added

* remove unwanted changes

* fix tests and check error

* PR feedback

* Update pkg/registry/apis/iam/resourcepermission/sql.go

---------

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2025-09-12 10:43:51 +01:00
Gabriel MABILLE ddbc5bce4f
`grafana-iam`: Use namespace for dbHelper (#110888) 2025-09-10 18:08:42 +02:00
Gabriel MABILLE 5c6fd5e5af
`grafana-iam`: Implement `resourcepermission` list (#110769)
* WIP: List

* make toV0ResourcePermissions work with an ordered list of assignments to ensure consistency in the results

* Test templates

* Split list query in two. I clearly need scopePatterns

* Add pagination with offsets

* Remove unecessary comment

* implement listiterator

* add listiterator tests

* return the correct resource version

* use SkipIntegrationTestInShortMode

* No need for the extra check on pagination being correctly set

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

* Spec is out of date

* Remove wrong comment

* Add a test for the pagination token

---------

Co-authored-by: mohammad-hamid <mohammad.hamid@grafana.com>
Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2025-09-10 11:17:53 +02:00
Ieva d692303e76
AuthZ: Deleting managed role permissions for a specified resource (#110617)
* basics for deleting managed role permissions for a specified resource

* fix the query

* fix query tests

* storage tests

* sql tests

* add missing import

* Update pkg/registry/apis/iam/resourcepermission/storage_backend.go

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

* PR feedback

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

---------

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2025-09-05 16:22:09 +01:00
Gabriel MABILLE 801fde02a7
`grafana-iam`: Implement `resourcepermission` creation (#110246)
* Extract from #108753

Co-Authored-By: mohammad-hamid <mohammad.hamid@grafana.com>

* Tackle create

Co-Authored-By: mohammad-hamid <mohammad.hamid@grafana.com>

* WIP use identity store to resolve role names

* WIP

* create role

* Remove unecessary comments

* comments

* sql templates

* test role insert tplt

* Add tests 😅

* Test permission insert template

* Test permission delete template

* Test assignment_insert template

* Manually test insertion

* Remove delete permissions. This is a create case we don't have permissions for that resource

* generate name handled by the apiserver library

* Remove comment and conversion

* Small renaming nits

* changes from main

* Add storage backend tests

* Add test to sql

* Test role contains a unique permission

* linting

* Account for pr feedback

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

* Reuse mappers

* Move function to models

* Add check between name and spec resource

* Check if the resource does not already exist

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

* fix query

* Check basic roles

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

* Account for error

* Make struct names consistent

* Nit. I prefer createAndAssignManagedRole

* Remove notifyign

* log errors instead of returning them

* Fix exist query join

* Test errors

* Remove dup

---------

Co-authored-by: mohammad-hamid <mohammad.hamid@grafana.com>
Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2025-09-05 14:22:25 +02:00
mohammad-hamid abcdf20105
`grafana-iam`: Implement `resourcepermission` get (#110256)
* resource permissions get

* address review feedback

* address comments
- read using rp name
- narrow by scope and actionsets
- update sql tests

* align with verb simplification

* keep original format to avoid conflicts

* add sqltests

* cleanup

* Remove unecessary errors

* Move query template to queries

* Use splitN to make sure we have three parts

* Revert user permission management for now. We don't need it

* Revert error change

* group permissions by resource

* extract parse scope

* Move sql_test

* Move & test parseScope

* Add tests to getResourcePermission

* Linting

* Use namespace

* Add test to the backend

* Ongoing tests

* Remove pagination, fix query boolean, insert basic role binding

* Linting

* Straightened the created and updated times

* error handling and uniformization with other backend

* Restore comments to avoid later conflicts

* Integration testing

* switch to function, no need to make it a method

* isServiceAccount should default to FALSE instead of TRUE :surprised:

* PR feedback

* Sort spec permissions

* Shouldn't happen but double proofing

---------

Co-authored-by: Gabriel Mabille <gabriel.mabille@grafana.com>
2025-09-04 17:14:15 +02:00
Gabriel MABILLE b6226c6173
`grafana-iam`: Skeleton of the resource permission api backend (#110218)
* Extract from #108753

Co-Authored-By: mohammad-hamid <mohammad.hamid@grafana.com>

* Tackle create

Co-Authored-By: mohammad-hamid <mohammad.hamid@grafana.com>

* WIP use identity store to resolve role names

* Commit empty service for now

* Clean

* For now only show name and created at

---------

Co-authored-by: mohammad-hamid <mohammad.hamid@grafana.com>
2025-08-27 15:00:09 +02:00