Skip to content

Commit 79ad19e

Browse files
committed
Fix RBAC service account permission checks
1 parent d7df1dc commit 79ad19e

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Then, create a service account token for the newly created service account and s
2424

2525
> Warning, Angular private plugins will be ignored from the scan when using Grafana <= 10.1.0.
2626
27-
Create a service account, with `Plugins / Plugin Writer` permissions (or "Admin" if using OSS without RBAC).
27+
Create a service account, with `Plugins / Plugin Maintainer` permissions (or "Admin" if using OSS without RBAC).
2828

2929
The reason behind admin rights is that the plugins endpoint returns all plugins only if the token can view and install plugins.
3030

main.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,15 @@ func _main() error {
7575
// as we may be running against an old Grafana version without service accounts
7676
log.Logf("(WARNING: could not get service account permissions: %v)", err)
7777
log.Logf("Please make sure that you have created an ADMIN token or the output will be wrong")
78-
} else if _, ok := permissions["datasources:create"]; !ok {
79-
return fmt.Errorf(
80-
`the service account does not have "datasources:create" permission, please provide a ` +
81-
"token for a service account with admin privileges",
82-
)
78+
} else {
79+
_, hasDsCreate := permissions["datasources:create"]
80+
_, hasPluginsInstall := permissions["plugins:install"]
81+
if !hasDsCreate && !hasPluginsInstall {
82+
return fmt.Errorf(
83+
`the service account does not have "datasources:create" or "plugins:install" permission, ` +
84+
"please provide a token for a service account with admin privileges",
85+
)
86+
}
8387
}
8488

8589
// Get the plugins

0 commit comments

Comments
 (0)