Skip to content

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

fix: make the conditions optional in casl check

sidwebworksd749a9621f86
diff --git a/backend/src/ee/services/event/event-sse-stream.ts b/backend/src/ee/services/event/event-sse-stream.ts
index d73eccb42c..0b7607ee51 100644
--- a/backend/src/ee/services/event/event-sse-stream.ts
+++ b/backend/src/ee/services/event/event-sse-stream.ts
@@ -71,8 +71,12 @@ export function createEventStreamClient(redis: Redis, options: IEventStreamClien
action: "subscribe",
conditions: {
eventType: r.event,
- secretPath: r.conditions?.secretPath ?? "/",
- environment: r.conditions?.environmentSlug
+ ...(r.conditions
+ ? {
+ secretPath: r.conditions?.secretPath,
+ environment: r.conditions?.environmentSlug
+ }
+ : {})
}
}));
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 72b283a0fc..17f13d3c22 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -69,7 +69,8 @@ export enum ApiDocsTags {
SecretScanning = "Secret Scanning",
OidcSso = "OIDC SSO",
SamlSso = "SAML SSO",
- LdapSso = "LDAP SSO"
+ LdapSso = "LDAP SSO",
+ Events = "Event Subscriptions"
}
export const GROUPS = {
@@ -2869,3 +2870,10 @@ export const LdapSso = {
caCert: "The CA certificate to use when verifying the LDAP server certificate."
}
};
+
+export const EventSubscriptions = {
+ SUBSCRIBE_PROJECT_EVENTS: {
+ projectId: "The ID of the project the group belongs to.",
+ register: "List of events you want to subscribe to"
+ }
+};
diff --git a/backend/src/server/routes/v1/event-router.ts b/backend/src/server/routes/v1/event-router.ts
index b8a043db55..dd6932c9a2 100644
--- a/backend/src/server/routes/v1/event-router.ts
+++ b/backend/src/server/routes/v1/event-router.ts
@@ -7,6 +7,7 @@ import { ActionProjectType, ProjectType } from "@app/db/schemas";
import { getServerSentEventsHeaders } from "@app/ee/services/event/event-sse-stream";
import { EventRegisterSchema } from "@app/ee/services/event/types";
import { ProjectPermissionSecretActions, ProjectPermissionSub } from "@app/ee/services/permission/project-permission";
+import { ApiDocsTags, EventSubscriptions } from "@app/lib/api-docs";
import { BadRequestError, ForbiddenRequestError, RateLimitError } from "@app/lib/errors";
import { readLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
@@ -20,10 +21,14 @@ export const registerEventRouter = async (server: FastifyZodProvider) => {
rateLimit: readLimit
},
schema: {
+ hide: false,
+ tags: [ApiDocsTags.Events],
+ description: "Subscribe to project events",
body: z.object({
- projectId: z.string().trim(),
+ projectId: z.string().trim().describe(EventSubscriptions.SUBSCRIBE_PROJECT_EVENTS.projectId),
register: z.array(EventRegisterSchema).max(10)
- })
+ }),
+ produces: ["text/event-stream"]
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req, reply) => {