Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

fix(documents): user must be in org to upload (#660)

Bartek Kwiecien9b43bafe3337
diff --git a/.changeset/hungry-walls-brush.md b/.changeset/hungry-walls-brush.md
new file mode 100644
index 00000000..3787cfe0
--- /dev/null
+++ b/.changeset/hungry-walls-brush.md
@@ -0,0 +1,5 @@
+---
+"@papra/app-server": patch
+---
+
+Removed the possibility for unauthorized upload to another organization you're not member of
diff --git a/apps/papra-server/src/modules/documents/documents.routes.ts b/apps/papra-server/src/modules/documents/documents.routes.ts
index a18a1751..3a4e0736 100644
--- a/apps/papra-server/src/modules/documents/documents.routes.ts
+++ b/apps/papra-server/src/modules/documents/documents.routes.ts
@@ -34,7 +34,7 @@ export function registerDocumentsRoutes(context: RouteDefinitionContext) {
}
function setupCreateDocumentRoute({ app, ...deps }: RouteDefinitionContext) {
- const { config } = deps;
+ const { config, db } = deps;
app.post(
'/api/organizations/:organizationId/documents',
@@ -46,6 +46,9 @@ function setupCreateDocumentRoute({ app, ...deps }: RouteDefinitionContext) {
const { userId } = getUser({ context });
const { organizationId } = context.req.valid('param');
+ const organizationsRepository = createOrganizationsRepository({ db });
+ await ensureUserIsInOrganization({ userId, organizationId, organizationsRepository });
+
const { maxUploadSize } = config.documentsStorage;
const { fileStream, fileName, mimeType } = await getFileStreamFromMultipartForm({