Skip to content

Commit

Permalink
Merge pull request #103 from zprebosnyak-lm/main
Browse files Browse the repository at this point in the history
  • Loading branch information
nscuro authored Jul 31, 2024
2 parents 59d07df + e697abe commit 5044896
Show file tree
Hide file tree
Showing 28 changed files with 924 additions and 164 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
60 changes: 57 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,44 @@ 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 +56,33 @@ 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 5044896

Please sign in to comment.