Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission deconstruction #103

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/containers/DefaultContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
ProfileEditModal,
SnapshotModal,
AppSidebar,
AppAside,

Check failure on line 50 in src/containers/DefaultContainer.vue

View workflow job for this annotation

GitHub Actions / lint

The "AppAside" component has been registered but not used
Breadcrumb,
DefaultHeaderProfileDropdown,

Check failure on line 52 in src/containers/DefaultContainer.vue

View workflow job for this annotation

GitHub Actions / lint

The "DefaultHeaderProfileDropdown" component has been registered but not used
SidebarForm,
SidebarFooter,
SidebarHeader,
Expand Down Expand Up @@ -126,19 +126,37 @@
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
Loading