mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 09:28:06 +00:00
feat: fixed test, resolved another edgecase in dashboard and added label to conditions in secrets
This commit is contained in:
@@ -812,6 +812,8 @@ describe.each([{ auth: AuthMode.JWT }, { auth: AuthMode.IDENTITY_ACCESS_TOKEN }]
|
|||||||
},
|
},
|
||||||
body: createSecretReqBody
|
body: createSecretReqBody
|
||||||
});
|
});
|
||||||
|
console.log(">>>>>>>>>>");
|
||||||
|
console.log(createSecRes.payload);
|
||||||
expect(createSecRes.statusCode).toBe(200);
|
expect(createSecRes.statusCode).toBe(200);
|
||||||
const createdSecretPayload = JSON.parse(createSecRes.payload);
|
const createdSecretPayload = JSON.parse(createSecRes.payload);
|
||||||
expect(createdSecretPayload).toHaveProperty("secret");
|
expect(createdSecretPayload).toHaveProperty("secret");
|
||||||
|
|||||||
@@ -441,7 +441,7 @@ export const permissionDALFactory = (db: TDbClient) => {
|
|||||||
.on(`${TableName.Identity}.id`, `${TableName.IdentityMetadata}.identityId`)
|
.on(`${TableName.Identity}.id`, `${TableName.IdentityMetadata}.identityId`)
|
||||||
.andOn(`${TableName.Project}.orgId`, `${TableName.IdentityMetadata}.orgId`);
|
.andOn(`${TableName.Project}.orgId`, `${TableName.IdentityMetadata}.orgId`);
|
||||||
})
|
})
|
||||||
.where("identityId", identityId)
|
.where(`${TableName.IdentityProjectMembership}.identityId`, identityId)
|
||||||
.where(`${TableName.IdentityProjectMembership}.projectId`, projectId)
|
.where(`${TableName.IdentityProjectMembership}.projectId`, projectId)
|
||||||
.select(selectAllTableCols(TableName.IdentityProjectMembershipRole))
|
.select(selectAllTableCols(TableName.IdentityProjectMembershipRole))
|
||||||
.select(
|
.select(
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (includeDynamicSecrets) {
|
if (includeDynamicSecrets && permissiveEnvs.length) {
|
||||||
// this is the unique count, ie duplicate secrets across envs only count as 1
|
// this is the unique count, ie duplicate secrets across envs only count as 1
|
||||||
totalDynamicSecretCount = await server.services.dynamicSecret.getCountMultiEnv({
|
totalDynamicSecretCount = await server.services.dynamicSecret.getCountMultiEnv({
|
||||||
actor: req.permission.type,
|
actor: req.permission.type,
|
||||||
@@ -241,7 +241,7 @@ export const registerDashboardRouter = async (server: FastifyZodProvider) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeSecrets) {
|
if (includeSecrets && permissiveEnvs.length) {
|
||||||
// this is the unique count, ie duplicate secrets across envs only count as 1
|
// this is the unique count, ie duplicate secrets across envs only count as 1
|
||||||
totalSecretCount = await server.services.secret.getSecretsCountMultiEnv({
|
totalSecretCount = await server.services.secret.getSecretsCountMultiEnv({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
|
|||||||
+1
@@ -93,6 +93,7 @@ export const GeneralPermissionOptions = <T extends keyof NonNullable<TFormSchema
|
|||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<div className="flex items-center justify-center">
|
<div className="flex items-center justify-center">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
|
isDisabled={isDisabled}
|
||||||
isChecked={Boolean(field.value)}
|
isChecked={Boolean(field.value)}
|
||||||
onCheckedChange={field.onChange}
|
onCheckedChange={field.onChange}
|
||||||
id={`permissions.${subject}.${rootIndex}.${String(value)}`}
|
id={`permissions.${subject}.${rootIndex}.${String(value)}`}
|
||||||
|
|||||||
+89
-78
@@ -12,8 +12,14 @@ type Props = {
|
|||||||
isDisabled?: boolean;
|
isDisabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getValueLabel = (type: string) => {
|
||||||
|
if (type === "environment") return "Environment slug";
|
||||||
|
if (type === "secretPath") return "Folder path";
|
||||||
|
return "";
|
||||||
|
};
|
||||||
|
|
||||||
export const SecretPermissionConditions = ({ position = 0, isDisabled }: Props) => {
|
export const SecretPermissionConditions = ({ position = 0, isDisabled }: Props) => {
|
||||||
const { control } = useFormContext<TFormSchema>();
|
const { control, watch } = useFormContext<TFormSchema>();
|
||||||
const items = useFieldArray({
|
const items = useFieldArray({
|
||||||
control,
|
control,
|
||||||
name: `permissions.secrets.${position}.conditions`
|
name: `permissions.secrets.${position}.conditions`
|
||||||
@@ -22,86 +28,91 @@ export const SecretPermissionConditions = ({ position = 0, isDisabled }: Props)
|
|||||||
return (
|
return (
|
||||||
<div className="mt-6 border-t border-t-gray-800 bg-mineshaft-800 pt-2">
|
<div className="mt-6 border-t border-t-gray-800 bg-mineshaft-800 pt-2">
|
||||||
<div className="mt-2 flex flex-col space-y-2">
|
<div className="mt-2 flex flex-col space-y-2">
|
||||||
{items.fields.map((el, index) => (
|
{items.fields.map((el, index) => {
|
||||||
<div
|
const lhs = watch(`permissions.secrets.${position}.conditions.${index}.lhs`);
|
||||||
key={el.id}
|
return (
|
||||||
className="flex gap-2 bg-mineshaft-800 first:rounded-t-md last:rounded-b-md"
|
<div
|
||||||
>
|
key={el.id}
|
||||||
<div className="w-1/4">
|
className="flex gap-2 bg-mineshaft-800 first:rounded-t-md last:rounded-b-md"
|
||||||
<Controller
|
>
|
||||||
control={control}
|
<div className="w-1/4">
|
||||||
name={`permissions.secrets.${position}.conditions.${index}.lhs`}
|
<Controller
|
||||||
render={({ field, fieldState: { error } }) => (
|
control={control}
|
||||||
<FormControl
|
name={`permissions.secrets.${position}.conditions.${index}.lhs`}
|
||||||
isError={Boolean(error?.message)}
|
render={({ field, fieldState: { error } }) => (
|
||||||
errorText={error?.message}
|
<FormControl
|
||||||
className="mb-0"
|
isError={Boolean(error?.message)}
|
||||||
>
|
errorText={error?.message}
|
||||||
<Select
|
className="mb-0"
|
||||||
defaultValue={field.value}
|
|
||||||
{...field}
|
|
||||||
onValueChange={(e) => field.onChange(e)}
|
|
||||||
className="w-full"
|
|
||||||
>
|
>
|
||||||
<SelectItem value="environment">Environment</SelectItem>
|
<Select
|
||||||
<SelectItem value="secretPath">Secret Path</SelectItem>
|
defaultValue={field.value}
|
||||||
</Select>
|
{...field}
|
||||||
</FormControl>
|
onValueChange={(e) => field.onChange(e)}
|
||||||
)}
|
className="w-full"
|
||||||
/>
|
>
|
||||||
</div>
|
<SelectItem value="environment">Environment</SelectItem>
|
||||||
<div className="w-36">
|
<SelectItem value="secretPath">Secret Path</SelectItem>
|
||||||
<Controller
|
</Select>
|
||||||
control={control}
|
</FormControl>
|
||||||
name={`permissions.secrets.${position}.conditions.${index}.operator`}
|
)}
|
||||||
render={({ field, fieldState: { error } }) => (
|
/>
|
||||||
<FormControl
|
</div>
|
||||||
isError={Boolean(error?.message)}
|
<div className="w-36">
|
||||||
errorText={error?.message}
|
<Controller
|
||||||
className="mb-0 flex-grow"
|
control={control}
|
||||||
>
|
name={`permissions.secrets.${position}.conditions.${index}.operator`}
|
||||||
<Select
|
render={({ field, fieldState: { error } }) => (
|
||||||
defaultValue={field.value}
|
<FormControl
|
||||||
{...field}
|
isError={Boolean(error?.message)}
|
||||||
onValueChange={(e) => field.onChange(e)}
|
errorText={error?.message}
|
||||||
className="w-full"
|
className="mb-0 flex-grow"
|
||||||
>
|
>
|
||||||
<SelectItem value={PermissionConditionOperators.$EQ}>Equal</SelectItem>
|
<Select
|
||||||
<SelectItem value={PermissionConditionOperators.$NEQ}>Not Equal</SelectItem>
|
defaultValue={field.value}
|
||||||
<SelectItem value={PermissionConditionOperators.$GLOB}>Glob Match</SelectItem>
|
{...field}
|
||||||
<SelectItem value={PermissionConditionOperators.$IN}>Contains</SelectItem>
|
onValueChange={(e) => field.onChange(e)}
|
||||||
</Select>
|
className="w-full"
|
||||||
</FormControl>
|
>
|
||||||
)}
|
<SelectItem value={PermissionConditionOperators.$EQ}>Equal</SelectItem>
|
||||||
/>
|
<SelectItem value={PermissionConditionOperators.$NEQ}>Not Equal</SelectItem>
|
||||||
|
<SelectItem value={PermissionConditionOperators.$GLOB}>
|
||||||
|
Glob Match
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value={PermissionConditionOperators.$IN}>Contains</SelectItem>
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="flex-grow">
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name={`permissions.secrets.${position}.conditions.${index}.rhs`}
|
||||||
|
render={({ field, fieldState: { error } }) => (
|
||||||
|
<FormControl
|
||||||
|
isError={Boolean(error?.message)}
|
||||||
|
errorText={error?.message}
|
||||||
|
className="mb-0 flex-grow"
|
||||||
|
>
|
||||||
|
<Input {...field} placeholder={getValueLabel(lhs)} />
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<IconButton
|
||||||
|
ariaLabel="plus"
|
||||||
|
variant="outline_bg"
|
||||||
|
className="p-2.5"
|
||||||
|
onClick={() => items.remove(index)}
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon icon={faTrash} />
|
||||||
|
</IconButton>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-grow">
|
);
|
||||||
<Controller
|
})}
|
||||||
control={control}
|
|
||||||
name={`permissions.secrets.${position}.conditions.${index}.rhs`}
|
|
||||||
render={({ field, fieldState: { error } }) => (
|
|
||||||
<FormControl
|
|
||||||
isError={Boolean(error?.message)}
|
|
||||||
errorText={error?.message}
|
|
||||||
className="mb-0 flex-grow"
|
|
||||||
>
|
|
||||||
<Input {...field} placeholder="value" />
|
|
||||||
</FormControl>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<IconButton
|
|
||||||
ariaLabel="plus"
|
|
||||||
variant="outline_bg"
|
|
||||||
className="p-2.5"
|
|
||||||
onClick={() => items.remove(index)}
|
|
||||||
>
|
|
||||||
<FontAwesomeIcon icon={faTrash} />
|
|
||||||
</IconButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -190,6 +190,7 @@ export const SecretOverviewPage = () => {
|
|||||||
}, [isWorkspaceLoading, workspaceId, router.isReady]);
|
}, [isWorkspaceLoading, workspaceId, router.isReady]);
|
||||||
|
|
||||||
const userAvailableEnvs = currentWorkspace?.environments || [];
|
const userAvailableEnvs = currentWorkspace?.environments || [];
|
||||||
|
|
||||||
const [visibleEnvs, setVisibleEnvs] = useState(userAvailableEnvs);
|
const [visibleEnvs, setVisibleEnvs] = useState(userAvailableEnvs);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user