Add read_channel_content permission (#24118)

* Add read_channel_content permission

* fix tests

* update system console default permissions per role

* add read_channel_content to e2e defaultRolesPermissions

* Migration to include custom roles

* change deprecated isNotExactRole for isNotRole

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Elias Nahum
2023-07-31 09:12:53 -04:00
коммит произвёл GitHub
родитель 047583947f
Коммит aa88f8bf59
24 изменённых файлов: 128 добавлений и 74 удалений

Просмотреть файл

@@ -1092,6 +1092,31 @@ func (a *App) getProductsBoardsPermissions() (permissionsMap, error) {
return transformations, nil
}
func (a *App) getAddChannelReadContentPermissions() (permissionsMap, error) {
t := []permissionTransformation{}
readChannelContentPermissions := []string{
model.PermissionReadChannelContent.Id,
}
// Migrate all roles including custom roles that have the read_channel permission
// but exclude system console roles system_read_only_admin system_user_manager & system_manager
// as this system roles are for the admin console use only
t = append(t, permissionTransformation{
On: permissionAnd(
permissionAnd(
isNotRole(model.SystemUserManagerRoleId),
isNotRole(model.SystemReadOnlyAdminRoleId),
isNotRole(model.SystemManagerRoleId),
),
permissionExists(model.PermissionReadChannel.Id),
),
Add: readChannelContentPermissions,
})
return t, nil
}
// DoPermissionsMigrations execute all the permissions migrations need by the current version.
func (a *App) DoPermissionsMigrations() error {
return a.Srv().doPermissionsMigrations()
@@ -1135,6 +1160,7 @@ func (s *Server) doPermissionsMigrations() error {
{Key: model.MigrationKeyAddPlayboosksManageRolesPermissions, Migration: a.getPlaybooksPermissionsAddManageRoles},
{Key: model.MigrationKeyAddProductsBoardsPermissions, Migration: a.getProductsBoardsPermissions},
{Key: model.MigrationKeyAddCustomUserGroupsPermissionRestore, Migration: a.getAddCustomUserGroupsPermissionRestore},
{Key: model.MigrationKeyAddReadChannelContentPermissions, Migration: a.getAddChannelReadContentPermissions},
}
roles, err := s.Store().Role().GetAll()