mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-09 23:28:31 +00:00
review fixes
This commit is contained in:
@@ -282,9 +282,14 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
|
|||||||
sshProductEnabled: z.boolean().optional(),
|
sshProductEnabled: z.boolean().optional(),
|
||||||
scannerProductEnabled: z.boolean().optional(),
|
scannerProductEnabled: z.boolean().optional(),
|
||||||
shareSecretsProductEnabled: z.boolean().optional(),
|
shareSecretsProductEnabled: z.boolean().optional(),
|
||||||
maxSharedSecretLifetime: z.number().max(2592000, "Max Shared Secret lifetime cannot exceed 30 days").optional(),
|
maxSharedSecretLifetime: z
|
||||||
|
.number()
|
||||||
|
.min(300, "Max Shared Secret lifetime cannot be under 5 minutes")
|
||||||
|
.max(2592000, "Max Shared Secret lifetime cannot exceed 30 days")
|
||||||
|
.optional(),
|
||||||
maxSharedSecretViewLimit: z
|
maxSharedSecretViewLimit: z
|
||||||
.number()
|
.number()
|
||||||
|
.min(1, "Max Shared Secret view count cannot be lower than 1")
|
||||||
.max(1000, "Max Shared Secret view count cannot exceed 1000")
|
.max(1000, "Max Shared Secret view count cannot exceed 1000")
|
||||||
.nullable()
|
.nullable()
|
||||||
.optional()
|
.optional()
|
||||||
|
|||||||
@@ -60,7 +60,9 @@ export const secretSharingServiceFactory = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const fiveMins = 5 * 60 * 1000;
|
const fiveMins = 5 * 60 * 1000;
|
||||||
if (expiryTime - currentTime < fiveMins) {
|
|
||||||
|
// 1 second buffer
|
||||||
|
if (expiryTime - currentTime + 1000 < fiveMins) {
|
||||||
throw new BadRequestError({ message: "Expiration time cannot be less than 5 mins" });
|
throw new BadRequestError({ message: "Expiration time cannot be less than 5 mins" });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+14
@@ -10,6 +10,7 @@ import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@a
|
|||||||
import { useUpdateOrg } from "@app/hooks/api";
|
import { useUpdateOrg } from "@app/hooks/api";
|
||||||
|
|
||||||
const MAX_SHARED_SECRET_LIFETIME_SECONDS = 30 * 24 * 60 * 60; // 30 days in seconds
|
const MAX_SHARED_SECRET_LIFETIME_SECONDS = 30 * 24 * 60 * 60; // 30 days in seconds
|
||||||
|
const MIN_SHARED_SECRET_LIFETIME_SECONDS = 5 * 60; // 5 minutes in seconds
|
||||||
|
|
||||||
// Helper function to convert duration to seconds
|
// Helper function to convert duration to seconds
|
||||||
const durationToSeconds = (value: number, unit: "m" | "h" | "d"): number => {
|
const durationToSeconds = (value: number, unit: "m" | "h" | "d"): number => {
|
||||||
@@ -77,6 +78,7 @@ const formSchema = z
|
|||||||
|
|
||||||
const durationInSeconds = durationToSeconds(maxLifetimeValue, maxLifetimeUnit);
|
const durationInSeconds = durationToSeconds(maxLifetimeValue, maxLifetimeUnit);
|
||||||
|
|
||||||
|
// Check max limit
|
||||||
if (durationInSeconds > MAX_SHARED_SECRET_LIFETIME_SECONDS) {
|
if (durationInSeconds > MAX_SHARED_SECRET_LIFETIME_SECONDS) {
|
||||||
let message = "Duration exceeds maximum allowed limit";
|
let message = "Duration exceeds maximum allowed limit";
|
||||||
|
|
||||||
@@ -94,6 +96,17 @@ const formSchema = z
|
|||||||
path: ["maxLifetimeValue"]
|
path: ["maxLifetimeValue"]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check min limit
|
||||||
|
if (durationInSeconds < MIN_SHARED_SECRET_LIFETIME_SECONDS) {
|
||||||
|
const message = `Duration must be at least ${MIN_SHARED_SECRET_LIFETIME_SECONDS / 60} minutes`; // 5 minutes
|
||||||
|
|
||||||
|
ctx.addIssue({
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
message,
|
||||||
|
path: ["maxLifetimeValue"]
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
type TForm = z.infer<typeof formSchema>;
|
type TForm = z.infer<typeof formSchema>;
|
||||||
@@ -187,6 +200,7 @@ export const OrgSecretShareLimitSection = () => {
|
|||||||
<FormControl
|
<FormControl
|
||||||
isError={Boolean(error)}
|
isError={Boolean(error)}
|
||||||
errorText={error?.message}
|
errorText={error?.message}
|
||||||
|
tooltipText="The max amount of time that can be set before the secret share link expires."
|
||||||
label="Max Lifetime"
|
label="Max Lifetime"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user