Skip to content

Commit 584bd19

Browse files
committed
Check for license permission
An auditor for example appears to have the view deployment values permission but cannot view licenses.
1 parent feafbe3 commit 584bd19

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

site/src/contexts/auth/permissions.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const checks = {
1515
createOrganization: "createOrganization",
1616
editAnyOrganization: "editAnyOrganization",
1717
viewAnyGroup: "viewAnyGroup",
18+
viewAllLicenses: "viewAllLicenses",
1819
} as const;
1920

2021
export const permissionsToCheck = {
@@ -117,6 +118,12 @@ export const permissionsToCheck = {
117118
},
118119
action: "read",
119120
},
121+
[checks.viewAllLicenses]: {
122+
object: {
123+
resource_type: "license",
124+
},
125+
action: "read",
126+
},
120127
} as const;
121128

122129
export type Permissions = Record<keyof typeof permissionsToCheck, boolean>;

site/src/pages/ManagementSettingsPage/SidebarView.stories.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ export const NoAuditLog: Story = {
4949
},
5050
};
5151

52+
export const NoLicenses: Story = {
53+
args: {
54+
permissions: {
55+
...MockPermissions,
56+
viewAllLicenses: false,
57+
},
58+
},
59+
};
60+
5261
export const NoDeploymentValues: Story = {
5362
args: {
5463
permissions: {

site/src/pages/ManagementSettingsPage/SidebarView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const DeploymentSettingsNavigation: FC<DeploymentSettingsNavigationProps> = (
112112
{props.permissions.viewDeploymentValues && (
113113
<SidebarNavSubItem href="general">General</SidebarNavSubItem>
114114
)}
115-
{props.permissions.viewDeploymentValues && (
115+
{props.permissions.viewAllLicenses && (
116116
<SidebarNavSubItem href="licenses">Licenses</SidebarNavSubItem>
117117
)}
118118
{props.permissions.editDeploymentValues && (

site/src/testHelpers/entities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2499,6 +2499,7 @@ export const MockPermissions: Permissions = {
24992499
createOrganization: true,
25002500
editAnyOrganization: true,
25012501
viewAnyGroup: true,
2502+
viewAllLicenses: true,
25022503
};
25032504

25042505
export const MockDeploymentConfig: DeploymentConfig = {

0 commit comments

Comments
 (0)