mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 11:29:42 +00:00
feat: permission changes
This commit is contained in:
@@ -9,10 +9,10 @@ export enum OrgPermissionActions {
|
||||
|
||||
export enum OrgGatewayPermissionActions {
|
||||
// is there a better word for this. This mean can an identity be a gateway
|
||||
Create = "create",
|
||||
Read = "read",
|
||||
Edit = "edit",
|
||||
Delete = "delete"
|
||||
CreateGateways = "create-gateways",
|
||||
ListGateways = "list-gateways",
|
||||
EditGateways = "edit-gateways",
|
||||
DeleteGateways = "delete-gateways"
|
||||
}
|
||||
|
||||
export enum OrgPermissionSubjects {
|
||||
|
||||
@@ -6,7 +6,7 @@ export type TGateway = {
|
||||
updatedAt: string;
|
||||
issuedAt: string;
|
||||
serialNumber: string;
|
||||
heartbeart: string;
|
||||
heartbeat: string;
|
||||
identity: {
|
||||
name: string;
|
||||
id: string;
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
faBookOpen,
|
||||
faEdit,
|
||||
faEllipsisV,
|
||||
faInfoCircle,
|
||||
faMagnifyingGlass,
|
||||
faPlug,
|
||||
faSearch,
|
||||
@@ -125,8 +126,18 @@ export const GatewayListPage = withPermission(
|
||||
<THead>
|
||||
<Tr>
|
||||
<Th className="w-1/3">Name</Th>
|
||||
<Th>Issued At</Th>
|
||||
<Th>Cert Issued At</Th>
|
||||
<Th>Identity</Th>
|
||||
<Th>
|
||||
Health Check
|
||||
<Tooltip
|
||||
asChild={false}
|
||||
className="normal-case"
|
||||
content="The last known healthcheck. Triggers every 1 hour."
|
||||
>
|
||||
<FontAwesomeIcon icon={faInfoCircle} className="ml-2" />
|
||||
</Tooltip>
|
||||
</Th>
|
||||
<Th className="w-5" />
|
||||
</Tr>
|
||||
</THead>
|
||||
@@ -140,8 +151,8 @@ export const GatewayListPage = withPermission(
|
||||
<Td>{format(new Date(el.issuedAt), "yyyy-MM-dd hh:mm:ss aaa")}</Td>
|
||||
<Td>{el.identity.name}</Td>
|
||||
<Td>
|
||||
{el.heartbeart
|
||||
? formatRelative(new Date(), new Date(el.heartbeart))
|
||||
{el.heartbeat
|
||||
? formatRelative(new Date(el.heartbeat), new Date())
|
||||
: "-"}
|
||||
</Td>
|
||||
<Td className="w-5">
|
||||
@@ -159,7 +170,7 @@ export const GatewayListPage = withPermission(
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<OrgPermissionCan
|
||||
I={OrgGatewayPermissionActions.Edit}
|
||||
I={OrgGatewayPermissionActions.EditGateways}
|
||||
a={OrgPermissionSubjects.Gateway}
|
||||
>
|
||||
{(isAllowed: boolean) => (
|
||||
|
||||
+4
-4
@@ -37,10 +37,10 @@ const kmipPermissionSchema = z
|
||||
|
||||
const orgGatewayPermissionSchema = z
|
||||
.object({
|
||||
[OrgGatewayPermissionActions.Read]: z.boolean().optional(),
|
||||
[OrgGatewayPermissionActions.Edit]: z.boolean().optional(),
|
||||
[OrgGatewayPermissionActions.Delete]: z.boolean().optional(),
|
||||
[OrgGatewayPermissionActions.Create]: z.boolean().optional()
|
||||
[OrgGatewayPermissionActions.ListGateways]: z.boolean().optional(),
|
||||
[OrgGatewayPermissionActions.EditGateways]: z.boolean().optional(),
|
||||
[OrgGatewayPermissionActions.DeleteGateways]: z.boolean().optional(),
|
||||
[OrgGatewayPermissionActions.CreateGateways]: z.boolean().optional()
|
||||
})
|
||||
.optional();
|
||||
|
||||
|
||||
+17
-17
@@ -24,10 +24,10 @@ enum Permission {
|
||||
}
|
||||
|
||||
const PERMISSION_ACTIONS = [
|
||||
{ action: OrgGatewayPermissionActions.Read, label: "Read" },
|
||||
{ action: OrgGatewayPermissionActions.Create, label: "Create" },
|
||||
{ action: OrgGatewayPermissionActions.Edit, label: "Modify" },
|
||||
{ action: OrgGatewayPermissionActions.Delete, label: "Remove" }
|
||||
{ action: OrgGatewayPermissionActions.ListGateways, label: "List Gateways" },
|
||||
{ action: OrgGatewayPermissionActions.CreateGateways, label: "Create Gateways" },
|
||||
{ action: OrgGatewayPermissionActions.EditGateways, label: "Edit Gateways" },
|
||||
{ action: OrgGatewayPermissionActions.DeleteGateways, label: "Delete Gateways" }
|
||||
] as const;
|
||||
|
||||
export const OrgGatewayPermissionRow = ({ isEditable, control, setValue }: Props) => {
|
||||
@@ -47,7 +47,7 @@ export const OrgGatewayPermissionRow = ({ isEditable, control, setValue }: Props
|
||||
if (isCustom) return Permission.Custom;
|
||||
if (score === 0) return Permission.NoAccess;
|
||||
if (score === totalActions) return Permission.FullAccess;
|
||||
if (score === 1 && rule?.[OrgGatewayPermissionActions.Read]) return Permission.ReadOnly;
|
||||
if (score === 1 && rule?.[OrgGatewayPermissionActions.ListGateways]) return Permission.ReadOnly;
|
||||
|
||||
return Permission.Custom;
|
||||
}, [rule, isCustom]);
|
||||
@@ -78,10 +78,10 @@ export const OrgGatewayPermissionRow = ({ isEditable, control, setValue }: Props
|
||||
setValue(
|
||||
"permissions.gateway",
|
||||
{
|
||||
[OrgGatewayPermissionActions.Read]: true,
|
||||
[OrgGatewayPermissionActions.Edit]: true,
|
||||
[OrgGatewayPermissionActions.Create]: true,
|
||||
[OrgGatewayPermissionActions.Delete]: true
|
||||
[OrgGatewayPermissionActions.ListGateways]: true,
|
||||
[OrgGatewayPermissionActions.EditGateways]: true,
|
||||
[OrgGatewayPermissionActions.CreateGateways]: true,
|
||||
[OrgGatewayPermissionActions.DeleteGateways]: true
|
||||
},
|
||||
{ shouldDirty: true }
|
||||
);
|
||||
@@ -90,10 +90,10 @@ export const OrgGatewayPermissionRow = ({ isEditable, control, setValue }: Props
|
||||
setValue(
|
||||
"permissions.gateway",
|
||||
{
|
||||
[OrgGatewayPermissionActions.Read]: true,
|
||||
[OrgGatewayPermissionActions.Edit]: false,
|
||||
[OrgGatewayPermissionActions.Create]: false,
|
||||
[OrgGatewayPermissionActions.Delete]: false
|
||||
[OrgGatewayPermissionActions.ListGateways]: true,
|
||||
[OrgGatewayPermissionActions.EditGateways]: false,
|
||||
[OrgGatewayPermissionActions.CreateGateways]: false,
|
||||
[OrgGatewayPermissionActions.DeleteGateways]: false
|
||||
},
|
||||
{ shouldDirty: true }
|
||||
);
|
||||
@@ -104,10 +104,10 @@ export const OrgGatewayPermissionRow = ({ isEditable, control, setValue }: Props
|
||||
setValue(
|
||||
"permissions.gateway",
|
||||
{
|
||||
[OrgGatewayPermissionActions.Read]: false,
|
||||
[OrgGatewayPermissionActions.Edit]: false,
|
||||
[OrgGatewayPermissionActions.Create]: false,
|
||||
[OrgGatewayPermissionActions.Delete]: false
|
||||
[OrgGatewayPermissionActions.ListGateways]: false,
|
||||
[OrgGatewayPermissionActions.EditGateways]: false,
|
||||
[OrgGatewayPermissionActions.CreateGateways]: false,
|
||||
[OrgGatewayPermissionActions.DeleteGateways]: false
|
||||
},
|
||||
{ shouldDirty: true }
|
||||
);
|
||||
|
||||
+7
-1
@@ -247,9 +247,15 @@ export const SqlDatabaseInputForm = ({
|
||||
className="w-full border border-mineshaft-500"
|
||||
dropdownContainerClassName="max-w-none"
|
||||
isLoading={isProjectGatewaysLoading}
|
||||
placeholder="Select gateway"
|
||||
placeholder="Internet gateway"
|
||||
position="popper"
|
||||
>
|
||||
<SelectItem
|
||||
value={null as unknown as string}
|
||||
onClick={() => onChange(undefined)}
|
||||
>
|
||||
Internet Gateway
|
||||
</SelectItem>
|
||||
{projectGateways?.map((el) => (
|
||||
<SelectItem value={el.id} key={el.id}>
|
||||
{el.name}
|
||||
|
||||
+7
-2
@@ -195,7 +195,9 @@ export const EditDynamicSecretSqlProviderForm = ({
|
||||
<FormControl
|
||||
isError={Boolean(error?.message) || isGatewayInActive}
|
||||
errorText={
|
||||
isGatewayInActive ? `Gateway ${selectedGatewayId} is removed` : error?.message
|
||||
isGatewayInActive && selectedGatewayId
|
||||
? `Gateway ${selectedGatewayId} is removed`
|
||||
: error?.message
|
||||
}
|
||||
label="Gateway"
|
||||
helperText=""
|
||||
@@ -206,9 +208,12 @@ export const EditDynamicSecretSqlProviderForm = ({
|
||||
className="w-full border border-mineshaft-500"
|
||||
dropdownContainerClassName="max-w-none"
|
||||
isLoading={isProjectGatewaysLoading}
|
||||
placeholder="Select gateway"
|
||||
placeholder="Internet Gateway"
|
||||
position="popper"
|
||||
>
|
||||
<SelectItem value={null as unknown as string} onClick={() => onChange(undefined)}>
|
||||
Internet Gateway
|
||||
</SelectItem>
|
||||
{projectGateways?.map((el) => (
|
||||
<SelectItem value={el.id} key={el.id}>
|
||||
{el.name}
|
||||
|
||||
Reference in New Issue
Block a user