Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
fix: validate connection belongs to team
Marc Seitz06736d8fb991
diff --git a/app/(ee)/api/teams/[teamId]/saml/route.ts b/app/(ee)/api/teams/[teamId]/saml/route.tsindex 272d982e..df532b4e 100644--- a/app/(ee)/api/teams/[teamId]/saml/route.ts+++ b/app/(ee)/api/teams/[teamId]/saml/route.ts@@ -318,7 +318,35 @@ export async function DELETE();}- await apiController.deleteConnections({ clientID, clientSecret });+ // Ownership check: verify the connection belongs to this team before deleting+ const existingConnections = await apiController.getConnections({+ clientID,+ });++ const connection = Array.isArray(existingConnections)+ ? existingConnections[0]+ : existingConnections;++ if (!connection) {+ return NextResponse.json(+ { error: "SAML connection not found" },+ { status: 404 },+ );+ }++ if (connection.tenant !== teamId) {+ return NextResponse.json(+ { error: "You do not have permission to delete this connection" },+ { status: 403 },+ );+ }++ await apiController.deleteConnections({+ clientID,+ clientSecret,+ tenant: teamId,+ product: jacksonProduct,+ });// Check if there are remaining connectionsconst remaining = await apiController.getConnections({