1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-05 05:45:22 +02:00

feat(stacks): prevent external stack removal by a non-administrator user (#3800)

* fix(stacks): prevent external stacks removal by non admin

* feat(stacks): add RBAC checks for external stack removals

Co-authored-by: Maxime Bajeux <max.bajeux@gmail.com>
This commit is contained in:
Anthony Lapenna 2020-05-13 15:37:35 +12:00 committed by GitHub
parent 29c0584454
commit 9dcd223134
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 15 deletions

View file

@ -2,17 +2,24 @@ angular.module('portainer.app').controller('StacksDatatableController', [
'$scope',
'$controller',
'DatatableService',
function ($scope, $controller, DatatableService) {
'Authentication',
function ($scope, $controller, DatatableService, Authentication) {
angular.extend(this, $controller('GenericDatatableController', { $scope: $scope }));
/**
* Do not allow external items
*/
this.allowSelection = function (item) {
return !(item.External && item.Type === 2);
if (item.External && item.Type === 2) {
return false;
}
return !(item.External && !this.isAdmin && !this.isEndpointAdmin);
};
this.$onInit = function () {
this.isAdmin = Authentication.isAdmin();
this.isEndpointAdmin = Authentication.hasAuthorizations(['EndpointResourcesAccess']);
this.setDefaults();
this.prepareTableFromDataset();