MM-36085: Split out System/Team Schemes from license feature checks. (#17727)
* 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 <william@gathoye.be> Co-authored-by: kaakaa <stooner.hoe@gmail.com> Co-authored-by: Nikolai Zahariev <nikolaiz@yahoo.com> Co-authored-by: Tóth Csaba // Online ERP Hungary Kft <csaba.toth@online-erp.hu> Co-authored-by: Kaya Zeren <kayazeren@gmail.com> Co-authored-by: LukasFiniarel <olli94fish@hotmail.de> Co-authored-by: JtheBAB <srast@bioc.uzh.ch> Co-authored-by: jprusch <rs@schaeferbarthold.de> Co-authored-by: Tom De Moor <tom@controlaltdieliet.be> Co-authored-by: Mattermod <mattermod@users.noreply.github.com> * 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 <emil.velikov@collabora.com> Co-authored-by: Emil Velikov <emil.velikov@collabora.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Weblate (bot) <hosted@weblate.org> Co-authored-by: wget <william@gathoye.be> Co-authored-by: kaakaa <stooner.hoe@gmail.com> Co-authored-by: Nikolai Zahariev <nikolaiz@yahoo.com> Co-authored-by: Tóth Csaba // Online ERP Hungary Kft <csaba.toth@online-erp.hu> Co-authored-by: Kaya Zeren <kayazeren@gmail.com> Co-authored-by: LukasFiniarel <olli94fish@hotmail.de> Co-authored-by: JtheBAB <srast@bioc.uzh.ch> Co-authored-by: jprusch <rs@schaeferbarthold.de> Co-authored-by: Tom De Moor <tom@controlaltdieliet.be> Co-authored-by: Emil Velikov <emil.l.velikov@gmail.com> Co-authored-by: Emil Velikov <emil.velikov@collabora.com>
Этот коммит содержится в:
коммит произвёл
Claudio Costa
родитель
da7d71ccf7
Коммит
77f9620997
28
api4/role.go
28
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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Ссылка в новой задаче
Block a user