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.

Prevent integration tokens from accessing API endpoints without explicit permissions

Kiran K4759edb15655
diff --git a/apps/web/lib/auth/workspace.ts b/apps/web/lib/auth/workspace.ts
index d9f76c51e5..032ae80612 100644
--- a/apps/web/lib/auth/workspace.ts
+++ b/apps/web/lib/auth/workspace.ts
@@ -145,6 +145,7 @@ export const withWorkspace = (
rateLimit: true,
projectId: true,
expires: true,
+ installationId: true,
}),
user: {
select: {
@@ -314,6 +315,15 @@ export const withWorkspace = (
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