3
0
mirror of https://github.com/grafana/grafana.git synced 2025-02-25 18:55:37 -06:00
Commit Graph

401 Commits

Author SHA1 Message Date
Aaron Godin
d409d8e860
IAM - Fix error messages for resource permissions endpoints ()
* IAM: fix many error messages in access-related code to provide more information

* Remove debug statement

* Refactor resourcepermissions package to use errutil

* Replace a few more errors with errutil and wrap errors found in users and teams services

* Apply diff of openAPI spec
2024-04-17 08:53:28 -05:00
Yuri Tseretyan
12605bfed2
Alerting: Update fixed roles to include silences permissions ()
* update fixed roles to include silences
* add silence actions to managed permissions
* update documentation
2024-04-12 12:37:34 -04:00
Karl Persson
73fecc8d80
Authn: Identity resolvers ()
* AuthN: Add NamespaceID struct. We should replace the usage of encoded namespaceID with this one

* AuthN: Add optional interface that clients can implement to be able to resolve identity for a namespace

* Authn: Implement IdentityResolverClient for api keys

* AuthN: use idenity resolvers

Co-authored-by: Misi <mgyongyosi@users.noreply.github.com>
2024-04-12 11:38:20 +02:00
Ieva
58059da10b
RBAC: Fix global role deletion in hosted Grafana ()
take into account the value of RBACSingleOrganization setting when determining org
2024-04-11 18:50:23 +01:00
Alexander Zobnin
3127566a20
Access control: Use ResolveIdentity() for authorizing in org ()
* Access control: Use ResolveIdentity() for authorizing in org

* Fix tests

* Fix middleware tests

* Use ResolveIdentity in HasGlobalAccess() function

* remove makeTmpUser

* Cleanup

* Fix linter errors

* Fix test build

* Remove GetUserPermissionsInOrg()
2024-04-10 12:42:13 +02:00
Yuri Tseretyan
509691b416
Alerting: Introduce authorization logic for operations on silences ()
* extract genericService from RuleService just to reuse it later
* implement silence service

---------

Co-authored-by: William Wernert <william.wernert@grafana.com>
Co-authored-by: Matthew Jacobson <matthew.jacobson@grafana.com>
2024-04-08 18:02:28 -04:00
Serge Zaitsev
faa1244518
Chore: Replace sqlstore with db interface ()
* replace sqlstore with db interface in a few packages

* remove from stats

* remove sqlstore in admin test

* remove sqlstore from api plugin tests

* fix another createUser

* remove sqlstore in publicdashboards

* remove sqlstore from orgs

* clean up orguser test

* more clean up in sso

* clean up service accounts

* further cleanup

* more cleanup in accesscontrol

* last cleanup in accesscontrol

* clean up teams

* more removals

* split cfg from db in testenv

* few remaining fixes

* fix test with bus

* pass cfg for testing inside db as an option

* set query retries when no opts provided

* revert golden test data

* rebase and rollback
2024-04-04 15:04:47 +02:00
Karl Persson
504870f10a
Auth: Decouple client and hook registration () 2024-04-04 09:33:00 +02:00
Ieva
beb15d938b
RBAC: Fix access checks for interactions with RBAC roles in hosted Grafana ()
* don't check global permissions for cloud instances

* linting
2024-04-03 11:44:16 +01:00
Jo
5340a6e548
Auth: Extended JWT client for OBO and Service Authentication ()
* reenable ext-jwt-client

* fixup settings struct

* add user and service auth

* lint up

* add user auth to grafana ext

* fixes

* Populate token permissions

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

* fix tests

* fix lint

* small prealloc

* small prealloc

* use special namespace for access policies

* fix access policy auth

* fix tests

* fix uncalled settings expander

* add feature toggle

* small feedback fixes

* rename entitlements to permissions

* add authlibn

* allow viewing the signed in user info for non user namespace

* fix invalid namespacedID

* use authlib as verifier for tokens

* Update pkg/services/authn/clients/ext_jwt.go

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

* Update pkg/services/authn/clients/ext_jwt_test.go

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

* fix parameter names

* change asserts to normal package

* add rule for assert

* fix ownerships

* Local diff

* test and lint

* Fix test

* Fix ac test

* Fix pluginproxy test

* Revert testdata changes

* Force revert on test data

---------

Co-authored-by: gamab <gabriel.mabille@grafana.com>
Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2024-04-02 17:45:15 +02:00
linoman
147154d2ea
Remove AuthConfigUIAdminAccess ()
* Remove AuthConfigUIAdminAccess
2024-04-02 15:02:28 +02:00
Karl Persson
5dd98a0fd5
RBAC: handle partially resolved scopes ()
* RBAC: handle partially resolved scopes

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2024-03-28 10:08:07 +01:00
Gabriel MABILLE
5e48804364
RBAC: Fix slow user permission search query on MySQL ()
* Bench testing search user perm

* Add BenchmarkSearchUsersPermissions_1K_1K

* Clarify benchmark searches by action prefix

* Make MySQL more efficient

* Move all filter options

* Expand after assignments union

* update comments
2024-03-25 19:11:17 +01:00
Yuri Tseretyan
48de8657c9
Alerting: Editor role can access all provisioning API () 2024-03-23 00:14:15 +02:00
Ieva
7aa0ba8c59
Teams: Display teams page to team reader if they also have the access to list team permissions ()
* display teams to team reader if they also have the access to list team permissions

* fix a typo in the docs
2024-03-18 14:52:01 +02:00
Alexander Zobnin
f36ad469d0
Access Control: Get global role from request params () 2024-03-14 16:17:24 +01:00
Alexander Zobnin
fd9031ca37
Access Control: Get org from request data for authorization ()
* Access Control: Get org from request data for authorization

* move type to models

* Update pkg/services/accesscontrol/middleware.go

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

* refactor

* refactor

* Fix linter

---------

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2024-03-13 17:05:03 +01:00
Misi
f5c78e0ad9
RBAC: Add ActionSettingsRead action to general.auth.config writer ()
Add ActionSettingsRead action to general.auth.config writer
2024-03-13 14:48:13 +01:00
Yuri Tseretyan
21719a6b5b
Chore: Fix log message in access control () 2024-03-07 23:34:22 +02:00
Karl Persson
22074c5026
RBAC: add debug log for permission evaluation ()
* fix: add debug log when evaluating permissions that includes target permissions
2024-03-05 08:50:19 +01:00
Alexander Zobnin
82a88cc83f
Access control: Extend GetUserPermissions() to query permissions in org ()
* Access control: Extend GetUserPermissions() to query permissions in specific org

* Use db query to fetch permissions in org

* refactor

* refactor

* use conditional join

* minor refactor

* Add test cases

* Search permissions correctly in OSS vs Enterprise

* Get permissions from memory

* Refactor

* remove unused func

* Add tests for GetUserPermissionsInOrg

* fix linter
2024-03-04 13:29:13 +01:00
Jo
0aebb9ee39
Misc: Remove unused params and impossible logic ()
* remove unused params and impossible logic

* remove unused param
2024-03-01 12:08:00 +01:00
Gabriel MABILLE
8d9921a5ba
RBAC: Fix delete team permissions on team delete ()
* RBAC: Remove team permissions on delete

* Remove unecessary deletes from store function

* Nit on mock

* Add test to the database

* Nit on comment

* Add another test to check that other permissions remain
2024-02-27 12:21:26 +01:00
Jo
cc3b088b6c
Teams: Fix missing context in team service ()
fix missing context in team service
2024-02-27 11:10:54 +01:00
Gabriel MABILLE
80d6bf6da0
AuthN: Remove embedded oauth server ()
* AuthN: Remove embedded oauth server

* Restore main

* go mod tidy

* Fix problem

* Remove permission intersection

* Fix test and lint

* Fix TestData test

* Revert to origin/main

* Update go.mod

* Update go.mod

* Update go.sum
2024-02-26 11:29:09 +01:00
Alexander Zobnin
9bbb7f67e0
Chore: Move store interface to top level ()
* Chore: Move store interface to top level

* Update store mock
2024-02-21 14:32:54 +01:00
Serge Zaitsev
1aff748e8f
Use split scopes instead of substr in search v1 ()
* use split scopes instead of substr in search v1

* tests, of course

* yet, some test helpers dont use split scopes

* another test helper to fix

* add permission.identifier to group by

* check if attribute is uid

* fix tests

* use SplitScope()

* fix more tests
2024-02-18 22:26:08 +01:00
Misi
bb9d5799cf
Auth: Load oauth_allow_insecure_email_lookup using the SettingsProvider ()
* wip

* Introduce fixed:server.config:writer role

* Fix tests

* Update name
2024-02-16 12:05:00 +01:00
Gabriel MABILLE
846eadff63
RBAC Search: Replace userLogin filter by namespacedID filter ()
* Add namespace ID

* Refactor and add tests

* Rename maxOneOption -> atMostOneOption

* Add ToDo

* Remove UserLogin & UserID for NamespaceID

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

* Remove unecessary import of the userSvc

* Update pkg/services/accesscontrol/acimpl/service.go

* fix 1 -> userID

* Update pkg/services/accesscontrol/accesscontrol.go

---------

Co-authored-by: jguer <joao.guerreiro@grafana.com>
2024-02-16 11:42:36 +01:00
Karl Persson
1315c67c8b
Team/User: UID migrations ()
* 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 ()
* 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 ()
* add slice copy method

* fix slice copy
2024-02-08 09:54:17 +01:00
William Wernert
2ab7d3c725
Alerting: Receivers API (read only endpoints) ()
* 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 ()
* 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 ()
* 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) ()
* 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 ()
* 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 () 2024-01-30 10:37:47 +01:00
Ieva
048d1e7c86
RBAC: Annotation permission migration ()
* 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 () 2024-01-26 12:23:48 +02:00
Gabriel MABILLE
19194ea122
RBAC: Remove redundant search endpoint () 2024-01-26 11:11:41 +02:00
Gabriel MABILLE
722b78f3e0
RBAC: Add userLogin filter to the permission search endpoint ()
* 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 ()
* 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 ()
* 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 () 2024-01-25 11:10:35 +01:00
Marcus Efraimsson
6768c6c059
Chore: Remove public vars in setting package ()
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 ()
* 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 ()
* 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 ()
* 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 ()
* clean up data source permissions after data source deletion

* remove a comment
2024-01-17 09:49:33 +00:00