fix: pr changes

This commit is contained in:
sidwebworks
2025-08-03 02:39:16 +05:30
parent 9fde0a5787
commit 806165b9e9
5 changed files with 35 additions and 34 deletions
@@ -66,19 +66,24 @@ export type EventStreamClient = {
}; };
export function createEventStreamClient(redis: Redis, options: IEventStreamClientOpts): EventStreamClient { export function createEventStreamClient(redis: Redis, options: IEventStreamClientOpts): EventStreamClient {
const rules = options.registered.map((r) => ({ const rules = options.registered.map((r) => {
subject: options.type, const secretPath = r.conditions?.secretPath;
action: "subscribe", const hasConditions = r.conditions?.environmentSlug || r.conditions?.secretPath;
conditions: {
eventType: r.event, return {
...(r.conditions subject: options.type,
? { action: "subscribe",
secretPath: r.conditions?.secretPath, conditions: {
environment: r.conditions?.environmentSlug eventType: r.event,
} ...(hasConditions
: {}) ? {
} environment: r.conditions?.environmentSlug ?? "",
})); secretPath: r.conditions?.recursive ? { $glob: `${secretPath}/**` } : secretPath
}
: {})
}
};
});
const id = `sse-${nanoid()}`; const id = `sse-${nanoid()}`;
const control = new AbortController(); const control = new AbortController();
+2 -1
View File
@@ -117,7 +117,8 @@ export const EventRegisterSchema = z.object({
conditions: z conditions: z
.object({ .object({
secretPath: z.string().optional().default("/"), secretPath: z.string().optional().default("/"),
environmentSlug: z.string() environmentSlug: z.string(),
recursive: z.boolean().optional().default(false)
}) })
.optional() .optional()
}); });
+10 -8
View File
@@ -80,13 +80,15 @@ export const registerEventRouter = async (server: FastifyZodProvider) => {
} }
req.body.register.forEach((r) => { req.body.register.forEach((r) => {
const fields = {
environment: r.conditions?.environmentSlug ?? "",
secretPath: r.conditions?.secretPath ?? "/",
eventType: r.event
};
const allowed = info.permission.can( const allowed = info.permission.can(
ProjectPermissionSecretActions.Subscribe, ProjectPermissionSecretActions.Subscribe,
subject(ProjectPermissionSub.Secrets, { subject(ProjectPermissionSub.Secrets, fields)
environment: r.conditions?.environmentSlug ?? "",
secretPath: r.conditions?.secretPath ?? "/",
eventType: r.event
})
); );
if (!allowed) { if (!allowed) {
@@ -94,9 +96,9 @@ export const registerEventRouter = async (server: FastifyZodProvider) => {
name: "PermissionDenied", name: "PermissionDenied",
message: `You are not allowed to subscribe on secrets`, message: `You are not allowed to subscribe on secrets`,
details: { details: {
event: r.event, event: fields.eventType,
environmentSlug: r.conditions?.environmentSlug, environmentSlug: fields.environment,
secretPath: r.conditions?.secretPath ?? "/" secretPath: fields.secretPath
} }
}); });
} }
@@ -5,20 +5,12 @@ description: "Subscribe to events in Infisical for real-time updates"
--- ---
<Info> <Info>
<strong>Note:</strong> Event Subscriptions is a paid feature. **Note:** Event Subscriptions is a paid feature. - **Infisical Cloud users:** Event Subscriptions is
<br /> available under the **Enterprise Tier**. - **Self-Hosted Infisical:** Please
<br /> contact [[email protected]](mailto:[email protected]) to purchase an
On Infisical Cloud, this feature is available on the <strong>
Pro
</strong> and <strong>Enterprise</strong> tiers, with each tier providing
different event retention periods.
<br />
For self-hosted deployments, please contact{" "}
<a href="mailto:[email protected]">[email protected]</a> to purchase an
enterprise license. enterprise license.
</Info> </Info>
## Introduction
Event Subscriptions in Infisical allow you to receive real-time notifications when specific actions occur within your account or organization. These notifications can include changes to secrets, users, teams, and other important resources. Event Subscriptions in Infisical allow you to receive real-time notifications when specific actions occur within your account or organization. These notifications can include changes to secrets, users, teams, and other important resources.
@@ -30,9 +22,10 @@ You can currently subscribe to notifications for the following event types:
- `secret:updated`: Triggered when a secret is updated. - `secret:updated`: Triggered when a secret is updated.
- `secret:deleted`: Triggered when a secret is deleted. - `secret:deleted`: Triggered when a secret is deleted.
## Permissions Setup ## Permissions Setup
Proper permissions are required to configure event subscriptions. Follow these steps to set up the necessary permissions: In order to receive events on a supported resource, the identity is required to have a Subscribe permission on that resource. Follow these steps to set up the necessary permissions:
<Steps> <Steps>
<Step title="Select a project and copy the 'Project ID'"> <Step title="Select a project and copy the 'Project ID'">
Binary file not shown.

Before

Width:  |  Height:  |  Size: 895 KiB

After

Width:  |  Height:  |  Size: 895 KiB