[v11.2.x] Folders: Add admin permissions upon creation of a folder w. SA (#95416)
Folders: Add admin permissions upon creation of a folder w. SA (#95072) * add admin permissions upon creation of a folder w. SA * Update pkg/services/folder/folderimpl/folder.go Co-authored-by: Karl Persson <kalle.persson@grafana.com> * Grant service account permissions for creation of dashboards * Grant service account admin permissions upon creating a datasource * fetch user using the userservice with the userid * Revert "fetch user using the userservice with the userid" This reverts commit23cba78752. * revert back to original datasource creation --------- Co-authored-by: Karl Persson <kalle.persson@grafana.com> (cherry picked from commit9ab064bfc5)
This commit is contained in:
+1
-1
@@ -194,7 +194,7 @@ func (hs *HTTPServer) setDefaultFolderPermissions(ctx context.Context, orgID int
|
|||||||
|
|
||||||
var permissions []accesscontrol.SetResourcePermissionCommand
|
var permissions []accesscontrol.SetResourcePermissionCommand
|
||||||
|
|
||||||
if identity.IsIdentityType(user.GetID(), identity.TypeUser) {
|
if identity.IsIdentityType(user.GetID(), identity.TypeUser, identity.TypeServiceAccount) {
|
||||||
userID, err := identity.UserIdentifier(user.GetID())
|
userID, err := identity.UserIdentifier(user.GetID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -492,7 +492,7 @@ func (dr *DashboardServiceImpl) setDefaultPermissions(ctx context.Context, dto *
|
|||||||
userID, err := identity.IntIdentifier(dto.User.GetID())
|
userID, err := identity.IntIdentifier(dto.User.GetID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dr.log.Error("Could not make user admin", "dashboard", dash.Title, "id", dto.User.GetID(), "error", err)
|
dr.log.Error("Could not make user admin", "dashboard", dash.Title, "id", dto.User.GetID(), "error", err)
|
||||||
} else if identity.IsIdentityType(dto.User.GetID(), identity.TypeUser) {
|
} else if identity.IsIdentityType(dto.User.GetID(), identity.TypeUser, identity.TypeServiceAccount) {
|
||||||
permissions = append(permissions, accesscontrol.SetResourcePermissionCommand{
|
permissions = append(permissions, accesscontrol.SetResourcePermissionCommand{
|
||||||
UserID: userID, Permission: dashboardaccess.PERMISSION_ADMIN.String(),
|
UserID: userID, Permission: dashboardaccess.PERMISSION_ADMIN.String(),
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user