Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix schemas

x032205391bdb099e6b
diff --git a/backend/src/services/approval-policy/pam-access/pam-access-policy-schemas.ts b/backend/src/services/approval-policy/pam-access/pam-access-policy-schemas.ts
index eb92b836fe..9fef86f8c4 100644
--- a/backend/src/services/approval-policy/pam-access/pam-access-policy-schemas.ts
+++ b/backend/src/services/approval-policy/pam-access/pam-access-policy-schemas.ts
@@ -17,28 +17,34 @@ export const PamAccessPolicyInputsSchema = z.object({
accountPath: z.string()
});
+const accountPathGlob = z.string().refine(
+ (el) => {
+ try {
+ picomatch.parse([el]);
+ return true;
+ } catch {
+ return false;
+ }
+ },
+ { message: "Invalid glob pattern" }
+);
+
// Conditions
export const PamAccessPolicyConditionsSchema = z
.object({
- accountPaths: z
- .string()
+ accountPaths: accountPathGlob.array()
+ })
+ .array();
+
+const MutatePamAccessPolicyConditionsSchema = z
+ .object({
+ accountPaths: accountPathGlob
.refine((el) => el.startsWith("/"), {
message: "Path must start with /"
})
.refine((el) => !el.endsWith("/"), {
message: "Path cannot end with /"
})
- .refine(
- (el) => {
- try {
- picomatch.parse([el]);
- return true;
- } catch {
- return false;
- }
- },
- { message: "Invalid glob pattern" }
- )
.array()
})
.array();
@@ -63,8 +69,12 @@ export const PamAccessPolicyConstraintsSchema = z.object({
// Request Data
export const PamAccessPolicyRequestDataSchema = z.object({
- accountPath: z
- .string()
+ accountPath: accountPathGlob,
+ accessDuration: DurationSchema
+});
+
+const CreatePamAccessPolicyRequestDataSchema = z.object({
+ accountPath: accountPathGlob
.refine((el) => el.startsWith("/"), {
message: "Path must start with /"
})
@@ -87,12 +97,12 @@ export const PamAccessPolicySchema = BaseApprovalPolicySchema.extend({
});
export const CreatePamAccessPolicySchema = BaseCreateApprovalPolicySchema.extend({
- conditions: PamAccessPolicyConditionsSchema,
+ conditions: MutatePamAccessPolicyConditionsSchema,
constraints: PamAccessPolicyConstraintsSchema
});
export const UpdatePamAccessPolicySchema = BaseUpdateApprovalPolicySchema.extend({
- conditions: PamAccessPolicyConditionsSchema.optional(),
+ conditions: MutatePamAccessPolicyConditionsSchema.optional(),
constraints: PamAccessPolicyConstraintsSchema.optional()
});
@@ -105,7 +115,7 @@ export const PamAccessRequestSchema = BaseApprovalRequestSchema.extend({
});
export const CreatePamAccessRequestSchema = BaseCreateApprovalRequestSchema.extend({
- requestData: PamAccessPolicyRequestDataSchema
+ requestData: CreatePamAccessPolicyRequestDataSchema
});
// Grants