mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Make rotationIntervalSeconds nullable
This commit is contained in:
@@ -10,7 +10,7 @@ export async function up(knex: Knex): Promise<void> {
|
||||
) {
|
||||
await knex.schema.alterTable(TableName.PamAccount, (t) => {
|
||||
t.boolean("rotationEnabled").notNullable().defaultTo(false);
|
||||
t.integer("rotationIntervalSeconds").notNullable();
|
||||
t.integer("rotationIntervalSeconds").nullable();
|
||||
t.timestamp("lastRotatedAt").nullable();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export const PamAccountsSchema = z.object({
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
rotationEnabled: z.boolean().default(false),
|
||||
rotationIntervalSeconds: z.number().default(2592000),
|
||||
rotationIntervalSeconds: z.number().nullable().optional(),
|
||||
lastRotatedAt: z.date().nullable().optional()
|
||||
});
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ export const registerPamResourceEndpoints = <C extends TPamAccount>({
|
||||
name: C["name"];
|
||||
description?: C["description"];
|
||||
rotationEnabled: C["rotationEnabled"];
|
||||
rotationIntervalSeconds: C["rotationIntervalSeconds"];
|
||||
rotationIntervalSeconds?: C["rotationIntervalSeconds"];
|
||||
}>;
|
||||
updateAccountSchema: z.ZodType<{
|
||||
credentials?: C["credentials"];
|
||||
|
||||
@@ -3798,7 +3798,7 @@ interface PamAccountCreateEvent {
|
||||
name: string;
|
||||
description?: string | null;
|
||||
rotationEnabled: boolean;
|
||||
rotationIntervalSeconds: number;
|
||||
rotationIntervalSeconds?: number | null;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3811,7 +3811,7 @@ interface PamAccountUpdateEvent {
|
||||
name?: string;
|
||||
description?: string | null;
|
||||
rotationEnabled?: boolean;
|
||||
rotationIntervalSeconds?: number;
|
||||
rotationIntervalSeconds?: number | null;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ export const pamAccountDALFactory = (db: TDbClient) => {
|
||||
const accounts = await dbClient(TableName.PamAccount)
|
||||
.innerJoin(TableName.PamResource, `${TableName.PamAccount}.resourceId`, `${TableName.PamResource}.id`)
|
||||
.whereNotNull(`${TableName.PamResource}.encryptedRotationAccountCredentials`)
|
||||
.whereNotNull(`${TableName.PamAccount}.rotationIntervalSeconds`)
|
||||
.whereRaw(
|
||||
`COALESCE("${TableName.PamAccount}"."lastRotatedAt", "${TableName.PamAccount}"."createdAt") + "${TableName.PamAccount}"."rotationIntervalSeconds" * interval '1 second' < NOW()`
|
||||
)
|
||||
|
||||
@@ -42,12 +42,12 @@ export const BaseCreatePamAccountSchema = z.object({
|
||||
name: slugSchema({ field: "name" }),
|
||||
description: z.string().max(512).nullable().optional(),
|
||||
rotationEnabled: z.boolean(),
|
||||
rotationIntervalSeconds: z.number().min(3600)
|
||||
rotationIntervalSeconds: z.number().min(3600).nullable().optional()
|
||||
});
|
||||
|
||||
export const BaseUpdatePamAccountSchema = z.object({
|
||||
name: slugSchema({ field: "name" }).optional(),
|
||||
description: z.string().max(512).nullable().optional(),
|
||||
rotationEnabled: z.boolean().optional(),
|
||||
rotationIntervalSeconds: z.number().min(3600).optional()
|
||||
rotationIntervalSeconds: z.number().min(3600).nullable().optional()
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ export interface TBasePamAccount {
|
||||
name: string;
|
||||
description?: string | null;
|
||||
rotationEnabled: boolean;
|
||||
rotationIntervalSeconds: number;
|
||||
rotationIntervalSeconds?: number | null;
|
||||
lastRotatedAt?: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
|
||||
@@ -6,7 +6,7 @@ import { FormControl, Select, SelectItem, Switch, Tooltip } from "@app/component
|
||||
|
||||
export const rotateAccountFieldsSchema = z.object({
|
||||
rotationEnabled: z.boolean(),
|
||||
rotationIntervalSeconds: z.number()
|
||||
rotationIntervalSeconds: z.number().nullable().optional()
|
||||
});
|
||||
|
||||
export const RotateAccountFields = ({
|
||||
@@ -16,7 +16,7 @@ export const RotateAccountFields = ({
|
||||
}) => {
|
||||
const { control, watch } = useFormContext<{
|
||||
rotationEnabled: boolean;
|
||||
rotationIntervalSeconds: number;
|
||||
rotationIntervalSeconds?: number | null;
|
||||
}>();
|
||||
|
||||
const rotationEnabled = watch("rotationEnabled");
|
||||
@@ -62,7 +62,7 @@ export const RotateAccountFields = ({
|
||||
className="mb-0"
|
||||
>
|
||||
<Select
|
||||
value={value.toString()}
|
||||
value={(value || 2592000).toString()}
|
||||
onValueChange={(val) => onChange(parseInt(val, 10))}
|
||||
className="w-full border border-mineshaft-500 capitalize"
|
||||
position="popper"
|
||||
|
||||
Reference in New Issue
Block a user