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:
parent
29c0584454
commit
9dcd223134
2 changed files with 48 additions and 15 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue