From dcae138379eaa576f1f367b5d958019a3b1bb7f6 Mon Sep 17 00:00:00 2001 From: Ieva Date: Fri, 12 Nov 2021 10:42:47 +0000 Subject: [PATCH] Access Control: adding group field to roles (#41465) * add group field to roles in AC models * change to using group_name as the column name * add a migration for group column --- pkg/services/accesscontrol/models.go | 3 +++ pkg/services/sqlstore/migrations/accesscontrol/migrations.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/pkg/services/accesscontrol/models.go b/pkg/services/accesscontrol/models.go index a59b9a123fd..2e4a0cb1b86 100644 --- a/pkg/services/accesscontrol/models.go +++ b/pkg/services/accesscontrol/models.go @@ -21,6 +21,7 @@ type Role struct { UID string `xorm:"uid" json:"uid"` Name string `json:"name"` DisplayName string `json:"displayName"` + Group string `xorm:"group_name" json:"group"` Description string `json:"description"` Updated time.Time `json:"updated"` @@ -61,6 +62,7 @@ type RoleDTO struct { Name string `json:"name"` DisplayName string `json:"displayName"` Description string `json:"description"` + Group string `xorm:"group_name" json:"group"` Permissions []Permission `json:"permissions,omitempty"` ID int64 `json:"-" xorm:"pk autoincr 'id'"` @@ -77,6 +79,7 @@ func (r RoleDTO) Role() Role { UID: r.UID, Name: r.Name, DisplayName: r.DisplayName, + Group: r.Group, Description: r.Description, Updated: r.Updated, Created: r.Created, diff --git a/pkg/services/sqlstore/migrations/accesscontrol/migrations.go b/pkg/services/sqlstore/migrations/accesscontrol/migrations.go index e708040569d..692a3d47ac3 100644 --- a/pkg/services/sqlstore/migrations/accesscontrol/migrations.go +++ b/pkg/services/sqlstore/migrations/accesscontrol/migrations.go @@ -49,6 +49,10 @@ func AddMigration(mg *migrator.Migrator) { mg.AddMigration("add column display_name", migrator.NewAddColumnMigration(roleV1, &migrator.Column{ Name: "display_name", Type: migrator.DB_NVarchar, Length: 190, Nullable: true, })) + + mg.AddMigration("add column group_name", migrator.NewAddColumnMigration(roleV1, &migrator.Column{ + Name: "group_name", Type: migrator.DB_NVarchar, Length: 190, Nullable: true, + })) //------- indexes ------------------ mg.AddMigration("add index role.org_id", migrator.NewAddIndexMigration(roleV1, roleV1.Indices[0])) mg.AddMigration("add unique index role_org_id_name", migrator.NewAddIndexMigration(roleV1, roleV1.Indices[1]))