From 77f9620997c7d69c2b217aaf440d581380298725 Mon Sep 17 00:00:00 2001 From: Martin Kraft Date: Tue, 20 Jul 2021 10:59:23 -0400 Subject: [PATCH] MM-36085: Split out System/Team Schemes from license feature checks. (#17727) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * MM-36085: Removes permissions whitelist for unlicensed instances. * MM-36095: Removes invalidated test. * Translations update from Weblate (#17947) * Translated using Weblate (French) Currently translated at 95.1% (2207 of 2319 strings) Translation: mattermost-languages-shipped/mattermost-server Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/fr/ * Translated using Weblate (Japanese) Currently translated at 100.0% (2319 of 2319 strings) Translation: mattermost-languages-shipped/mattermost-server Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/ja/ * Translated using Weblate (Bulgarian) Currently translated at 100.0% (2319 of 2319 strings) Translation: mattermost-languages-shipped/mattermost-server Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/bg/ * Translated using Weblate (Hungarian) Currently translated at 100.0% (2319 of 2319 strings) Translation: mattermost-languages-shipped/mattermost-server Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/hu/ * Translated using Weblate (Turkish) Currently translated at 100.0% (2319 of 2319 strings) Translation: mattermost-languages-shipped/mattermost-server Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/tr/ Translated using Weblate (Turkish) Currently translated at 100.0% (2319 of 2319 strings) Translation: mattermost-languages-shipped/mattermost-server Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/tr/ * Translated using Weblate (German) Currently translated at 83.7% (1943 of 2319 strings) Translation: mattermost-languages-shipped/mattermost-server Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/de/ * Translated using Weblate (German) Currently translated at 83.7% (1943 of 2319 strings) Translation: mattermost-languages-shipped/mattermost-server Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/de/ * Translated using Weblate (German) Currently translated at 84.2% (1953 of 2319 strings) Translation: mattermost-languages-shipped/mattermost-server Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/de/ * Translated using Weblate (Dutch) Currently translated at 100.0% (2319 of 2319 strings) Translation: mattermost-languages-shipped/mattermost-server Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/nl/ Co-authored-by: wget Co-authored-by: kaakaa Co-authored-by: Nikolai Zahariev Co-authored-by: Tóth Csaba // Online ERP Hungary Kft Co-authored-by: Kaya Zeren Co-authored-by: LukasFiniarel Co-authored-by: JtheBAB Co-authored-by: jprusch Co-authored-by: Tom De Moor Co-authored-by: Mattermod * Split package target into per platform (#17692) Currently the `package` make target handles all three platforms - Windows, OSX and Linux. While doing it in surprisingly serial mode. Split it up in 3, so that things are a bit faster and people can package only what they need. v2: Rebase (platform was removed) Signed-off-by: Emil Velikov Co-authored-by: Emil Velikov Co-authored-by: Mattermod Co-authored-by: Mattermod Co-authored-by: Weblate (bot) Co-authored-by: wget Co-authored-by: kaakaa Co-authored-by: Nikolai Zahariev Co-authored-by: Tóth Csaba // Online ERP Hungary Kft Co-authored-by: Kaya Zeren Co-authored-by: LukasFiniarel Co-authored-by: JtheBAB Co-authored-by: jprusch Co-authored-by: Tom De Moor Co-authored-by: Emil Velikov Co-authored-by: Emil Velikov --- api4/role.go | 28 +--------------------------- api4/role_test.go | 12 ------------ 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/api4/role.go b/api4/role.go index 06a0929817..25dd6ab0dc 100644 --- a/api4/role.go +++ b/api4/role.go @@ -10,18 +10,6 @@ import ( "github.com/mattermost/mattermost-server/v5/model" ) -var allowedPermissions = []string{ - model.PermissionCreateTeam.Id, - model.PermissionManageIncomingWebhooks.Id, - model.PermissionManageOutgoingWebhooks.Id, - model.PermissionManageSlashCommands.Id, - model.PermissionManageOAuth.Id, - model.PermissionManageSystemWideOAuth.Id, - model.PermissionCreateEmojis.Id, - model.PermissionDeleteEmojis.Id, - model.PermissionEditOthersPosts.Id, -} - var notAllowedPermissions = []string{ model.PermissionSysconsoleWriteUserManagementSystemRoles.Id, model.PermissionSysconsoleReadUserManagementSystemRoles.Id, @@ -129,23 +117,9 @@ func patchRole(c *Context, w http.ResponseWriter, r *http.Request) { c.Err = model.NewAppError("Api4.PatchRoles", "api.roles.patch_roles.license.error", nil, "", http.StatusNotImplemented) return } - - changedPermissions := model.PermissionsChangedByPatch(oldRole, patch) - for _, permission := range changedPermissions { - allowed := false - for _, allowedPermission := range allowedPermissions { - if permission == allowedPermission { - allowed = true - } - } - - if !allowed { - c.Err = model.NewAppError("Api4.PatchRoles", "api.roles.patch_roles.license.error", nil, "", http.StatusNotImplemented) - return - } - } } + // Licensed instances can not change permissions in the blacklist set. if patch.Permissions != nil { deltaPermissions := model.PermissionsChangedByPatch(oldRole, patch) diff --git a/api4/role_test.go b/api4/role_test.go index b1c4e417c6..ba95a48a3a 100644 --- a/api4/role_test.go +++ b/api4/role_test.go @@ -240,22 +240,10 @@ func TestPatchRole(t *testing.T) { _, resp = th.Client.PatchRole(role.Id, patch) CheckForbiddenStatus(t, resp) - // Check a change that the license would not allow. patch = &model.RolePatch{ Permissions: &[]string{"manage_system", "manage_incoming_webhooks", "manage_outgoing_webhooks"}, } - th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) { - _, resp := client.PatchRole(role.Id, patch) - CheckNotImplementedStatus(t, resp) - }) - - // Add a license. - license := model.NewTestLicense() - license.Features.GuestAccountsPermissions = model.NewBool(false) - th.App.Srv().SetLicense(license) - - // Try again, should succeed th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) { received, resp := client.PatchRole(role.Id, patch) CheckNoError(t, resp)