Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update workspace-edge.ts

Kiran K74a1fa16da7f
diff --git a/apps/web/lib/auth/workspace-edge.ts b/apps/web/lib/auth/workspace-edge.ts
index c8ec0aeb29..fd30dca43b 100644
--- a/apps/web/lib/auth/workspace-edge.ts
+++ b/apps/web/lib/auth/workspace-edge.ts
@@ -151,6 +151,7 @@ export const withWorkspaceEdge = (
rateLimit: true,
projectId: true,
expires: true,
+ installationId: true,
}),
user: {
select: {
@@ -298,6 +299,15 @@ export const withWorkspaceEdge = (
permissions = mapScopesToPermissions(tokenScopes).filter((p) =>
permissions.includes(p),
);
+
+ // Prevent integration tokens from accessing API endpoints without explicit permissions
+ if (token.installationId && requiredPermissions.length === 0) {
+ throw new DubApiError({
+ code: "forbidden",
+ message:
+ "You don't have the necessary permissions to complete this request.",
+ });
+ }
}
// Check user has permission to make the action