-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Missing plan check and ip whitelist parsing
- Loading branch information
Showing
2 changed files
with
31 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,14 +43,27 @@ export const updateApiIpWhitelist = rateLimitedProcedure(ratelimit.update) | |
"We are unable to update the API whitelist. Please try again or contact [email protected]", | ||
}); | ||
}); | ||
if (!api || api.workspace.tenantId !== ctx.tenant.id) { | ||
|
||
if ( | ||
!api || | ||
api.workspace.tenantId !== ctx.tenant.id || | ||
input.workspaceId !== api.workspace.id | ||
) { | ||
throw new TRPCError({ | ||
code: "NOT_FOUND", | ||
message: | ||
"We are unable to find the correct API. Please try again or contact [email protected].", | ||
}); | ||
} | ||
|
||
if (api.workspace.plan !== "enterprise") { | ||
throw new TRPCError({ | ||
code: "UNAUTHORIZED", | ||
message: | ||
"IP Whitelisting is only available for enterprise plans. Please contact [email protected].", | ||
}); | ||
} | ||
|
||
const newIpWhitelist = input.ipWhitelist === null ? null : input.ipWhitelist.join(","); | ||
|
||
await db | ||
|
@@ -68,6 +81,7 @@ export const updateApiIpWhitelist = rateLimitedProcedure(ratelimit.update) | |
"We are unable to update the API whitelist. Please try again or contact [email protected]", | ||
}); | ||
}); | ||
|
||
await insertAuditLogs(tx, { | ||
workspaceId: api.workspace.id, | ||
actor: { | ||
|