RBAC: Migration to remove the scope from permissions where action is alert.instances:read (#82202)
* add a migration to remove the scope from any permissions where action is alert.instances:read * linting
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package accesscontrol
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/migrator"
|
||||
)
|
||||
|
||||
const (
|
||||
AlertingScopeRemovalMigrationID = "removing scope from alert.instances:read action migration"
|
||||
)
|
||||
|
||||
func AddAlertingScopeRemovalMigration(mg *migrator.Migrator) {
|
||||
mg.AddMigration(AlertingScopeRemovalMigrationID, &alertingScopeRemovalMigrator{})
|
||||
}
|
||||
|
||||
var _ migrator.CodeMigration = new(alertingScopeRemovalMigrator)
|
||||
|
||||
type alertingScopeRemovalMigrator struct {
|
||||
permissionMigrator
|
||||
}
|
||||
|
||||
func (p *alertingScopeRemovalMigrator) SQL(dialect migrator.Dialect) string {
|
||||
return CodeMigrationSQL
|
||||
}
|
||||
|
||||
func (p *alertingScopeRemovalMigrator) Exec(sess *xorm.Session, migrator *migrator.Migrator) error {
|
||||
p.sess = sess
|
||||
p.dialect = migrator.Dialect
|
||||
_, err := p.sess.Exec("UPDATE permission SET `scope` = '', `kind` = '', `attribute` = '', `identifier` = '' WHERE action = ?", accesscontrol.ActionAlertingInstanceRead)
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user