Skip to content

Commit

Permalink
Permission deconstruction (#1)
Browse files Browse the repository at this point in the history
* fix: intial push for CI jobs

* fix: adding Node Full from pipeline catalog

* fix: disabling jobs

* fix: trying pipeline tepmplate

* fix: fix syntax error

* fix: enable node_ci job

* added artifacts for node-build

* fix spacing issue

* fix: addded curl request to add jq

* fix: replace cat with cmd

* fix: add \ and &&

* test: test directives permission logic

* test: different permission for directive

* test: revert old permissions test, test case with new permissions

* fix: copy pasta'd myself

* test: progress push

* test: temp

* test: ci updates

* feat: update UI for permissions

* fix: var name

* fix: revert to original values

---------

Co-authored-by: johnny mayer <[email protected]>
Co-authored-by: Mensah, Ephraim E <[email protected]>
Co-authored-by: Cortes, Noel <[email protected]>
Signed-off-by: Zachary Prebosnyak <[email protected]>
  • Loading branch information
4 people committed Jul 29, 2024
1 parent 0ffe7d6 commit e746037
Show file tree
Hide file tree
Showing 28 changed files with 548 additions and 161 deletions.
24 changes: 21 additions & 3 deletions src/containers/DefaultContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,37 @@ export default {
element: '',
attributes: {},
},
permission: permissions.SYSTEM_CONFIGURATION,
permission: [
permissions.SYSTEM_CONFIGURATION,
permissions.SYSTEM_CONFIGURATION_CREATE,
permissions.SYSTEM_CONFIGURATION_READ,
permissions.SYSTEM_CONFIGURATION_UPDATE,
permissions.SYSTEM_CONFIGURATION_DELETE
],
},
{
name: this.$t('message.policy_management'),
url: '/policy',
icon: 'fa fa-list-alt',
permission: permissions.POLICY_MANAGEMENT,
permission: [
permissions.POLICY_MANAGEMENT,
permissions.POLICY_MANAGEMENT_CREATE,
permissions.POLICY_MANAGEMENT_READ,
permissions.POLICY_MANAGEMENT_UPDATE,
permissions.POLICY_MANAGEMENT_DELETE
],
},
{
name: this.$t('message.administration'),
url: '/admin',
icon: 'fa fa-cogs',
permission: permissions.SYSTEM_CONFIGURATION,
permission: [
permissions.SYSTEM_CONFIGURATION,
permissions.SYSTEM_CONFIGURATION_CREATE,
permissions.SYSTEM_CONFIGURATION_READ,
permissions.SYSTEM_CONFIGURATION_UPDATE,
permissions.SYSTEM_CONFIGURATION_DELETE
],
},
],
};
Expand Down
56 changes: 53 additions & 3 deletions src/mixins/permissionsMixin.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable prettier/prettier */
import * as permissions from '../shared/permissions';

export default {
Expand All @@ -7,14 +8,38 @@ export default {
BOM_UPLOAD: permissions.BOM_UPLOAD,
VIEW_PORTFOLIO: permissions.VIEW_PORTFOLIO,
PORTFOLIO_MANAGEMENT: permissions.PORTFOLIO_MANAGEMENT,
ACCESS_MANAGEMENT: permissions.ACCESS_MANAGEMENT,
PORTFOLIO_MANAGEMENT_CREATE: permissions.PORTFOLIO_MANAGEMENT_CREATE,
PORTFOLIO_MANAGEMENT_READ: permissions.PORTFOLIO_MANAGEMENT_READ,
PORTFOLIO_MANAGEMENT_UPDATE: permissions.PORTFOLIO_MANAGEMENT_UPDATE,
PORTFOLIO_MANAGEMENT_DELETE: permissions.PORTFOLIO_MANAGEMENT_DELETE,
VIEW_VULNERABILITY: permissions.VIEW_VULNERABILITY,
VULNERABILITY_ANALYSIS: permissions.VULNERABILITY_ANALYSIS,
VULNERABILITY_ANALYSIS_CREATE: permissions.VULNERABILITY_ANALYSIS_CREATE,
VULNERABILITY_ANALYSIS_READ: permissions.VULNERABILITY_ANALYSIS_READ,
VULNERABILITY_ANALYSIS_UPDATE: permissions.VULNERABILITY_ANALYSIS_UPDATE,
VIEW_POLICY_VIOLATION: permissions.VIEW_POLICY_VIOLATION,
VULNERABILITY_MANAGEMENT: permissions.VULNERABILITY_MANAGEMENT,
VULNERABILITY_MANAGEMENT_CREATE: permissions.VULNERABILITY_MANAGEMENT_CREATE,
VULNERABILITY_MANAGEMENT_READ: permissions.VULNERABILITY_MANAGEMENT_READ,
VULNERABILITY_MANAGEMENT_UPDATE: permissions.VULNERABILITY_MANAGEMENT_UPDATE,
VULNERABILITY_MANAGEMENT_DELETE: permissions.VULNERABILITY_MANAGEMENT_DELETE,
POLICY_VIOLATION_ANALYSIS: permissions.POLICY_VIOLATION_ANALYSIS,
ACCESS_MANAGEMENT: permissions.ACCESS_MANAGEMENT,
ACCESS_MANAGEMENT_CREATE: permissions.ACCESS_MANAGEMENT_CREATE,
ACCESS_MANAGEMENT_READ: permissions.ACCESS_MANAGEMENT_READ,
ACCESS_MANAGEMENT_UPDATE: permissions.ACCESS_MANAGEMENT_UPDATE,
ACCESS_MANAGEMENT_DELETE: permissions.ACCESS_MANAGEMENT_DELETE,
SYSTEM_CONFIGURATION: permissions.SYSTEM_CONFIGURATION,
SYSTEM_CONFIGURATION_CREATE: permissions.SYSTEM_CONFIGURATION_CREATE,
SYSTEM_CONFIGURATION_READ: permissions.SYSTEM_CONFIGURATION_READ,
SYSTEM_CONFIGURATION_UPDATE: permissions.SYSTEM_CONFIGURATION_UPDATE,
SYSTEM_CONFIGURATION_DELETE: permissions.SYSTEM_CONFIGURATION_DELETE,
PROJECT_CREATION_UPLOAD: permissions.PROJECT_CREATION_UPLOAD,
POLICY_MANAGEMENT: permissions.POLICY_MANAGEMENT,
POLICY_MANAGEMENT_CREATE: permissions.POLICY_MANAGEMENT_CREATE,
POLICY_MANAGEMENT_READ: permissions.POLICY_MANAGEMENT_READ,
POLICY_MANAGEMENT_UPDATE: permissions.POLICY_MANAGEMENT_UPDATE,
POLICY_MANAGEMENT_DELETE: permissions.POLICY_MANAGEMENT_DELETE,
},
};
},
Expand All @@ -25,10 +50,35 @@ export default {
},
methods: {
isPermitted(permission) {
return permissions.hasPermission(permission, this.decodedToken);
// return permissions.hasPermission(permission, this.decodedToken);
if (typeof permission == 'string') {
return permissions.hasPermission(permission, this.decodedToken);
}
else if (Array.isArray(permission)) {
for (let perm of permission) {
if (permissions.hasPermission(perm, this.decodedToken)) {
return true;
}
}
return false;
} else {
throw new Error("permission must be of type string or array")
}
},
isNotPermitted(permission) {
return !permissions.hasPermission(permission, this.decodedToken);
if (typeof permission == 'string') {
return !permissions.hasPermission(permission, this.decodedToken);
}
else if (Array.isArray(permission)) {
for (let perm of permission) {
if (permissions.hasPermission(perm, this.decodedToken)) {
return false;
}
}
return true;
} else {
throw new Error("permission must be of type string or array")
}
},
},
};
Loading

0 comments on commit e746037

Please sign in to comment.