Question: where to set the 1GB attachment limit? #560

Closed
opened 2026-02-04 21:33:19 +03:00 by OVERLORD · 5 comments
Owner

Originally created by @pdarcos on GitHub (Jan 7, 2020).

Hi guys,

Maybe a dumb question , but where in the code is this logic handled?
Is it possible to set limits per account/organization or is it a global setting for everyone?

Cheers

Originally created by @pdarcos on GitHub (Jan 7, 2020). Hi guys, Maybe a dumb question , but where in the code is this logic handled? Is it possible to set limits per account/organization or is it a global setting for everyone? Cheers
Author
Owner

@dani-garcia commented on GitHub (Jan 8, 2020):

At the moment there isn't any attachment size limit.

@dani-garcia commented on GitHub (Jan 8, 2020): At the moment there isn't any attachment size limit.
Author
Owner

@pdarcos commented on GitHub (Jan 8, 2020):

Ah ok. Thanks for the answer @dani-garcia

Are there plans to implement that? I don't want some of my users abusing it and uploading GBs of data.

Where in the code should I be looking to implement this? Either per user or globally

Thanks

@pdarcos commented on GitHub (Jan 8, 2020): Ah ok. Thanks for the answer @dani-garcia Are there plans to implement that? I don't want some of my users abusing it and uploading GBs of data. Where in the code should I be looking to implement this? Either per user or globally Thanks
Author
Owner

@dani-garcia commented on GitHub (Jan 8, 2020):

At the moment there aren't any plans in progress but it's a welcome feature and it should be fairly easy to at least have a global limit.

This is where we save the file and we specifically set the size limit to None, then we save the file size in the attachments table.

baf7d1be4e/src/api/core/ciphers.rs (L677)

To put a global user limit we'd have to add all the sizes of that users attachments and then set that size_limit to LIMIT - (sum of all attachments sizes).
If we set 1Gb limit per user and I have 3 100Mb files, then the limit for the next one would be 700Mb for example. Then when the limit is exceeded I assume we'd get a SaveResult::Partial or a SaveResult::Error and we'd be done.

To have different limits for users we'd need to add a column to the users table and a way to change them in the admin page, but I think most people would be happy with a global user limit for now.

@dani-garcia commented on GitHub (Jan 8, 2020): At the moment there aren't any plans in progress but it's a welcome feature and it should be fairly easy to at least have a global limit. This is where we save the file and we specifically set the size limit to None, then we save the file size in the attachments table. https://github.com/dani-garcia/bitwarden_rs/blob/baf7d1be4e9a7e70de99c6005b09571bd17ff6f9/src/api/core/ciphers.rs#L677 To put a global user limit we'd have to add all the sizes of that users attachments and then set that `size_limit` to `LIMIT - (sum of all attachments sizes)`. If we set 1Gb limit per user and I have 3 100Mb files, then the limit for the next one would be 700Mb for example. Then when the limit is exceeded I assume we'd get a SaveResult::Partial or a SaveResult::Error and we'd be done. To have different limits for users we'd need to add a column to the users table and a way to change them in the admin page, but I think most people would be happy with a global user limit for now.
Author
Owner

@pdarcos commented on GitHub (Feb 4, 2020):

Thanks @dani-garcia !

Much appreciated

@pdarcos commented on GitHub (Feb 4, 2020): Thanks @dani-garcia ! Much appreciated
Author
Owner

@dani-garcia commented on GitHub (Feb 18, 2020):

Okay so I've implemented the size limit functionality, with two limits, one for users and another for organizations, so depending where the cipher is located it can be one or the other, and setting it to zero disables uploading at all. The options are USER_ATTACHMENT_LIMIT and ORG_ATTACHMENT_LIMIT and they use KB.

The commit: 325039c316

@dani-garcia commented on GitHub (Feb 18, 2020): Okay so I've implemented the size limit functionality, with two limits, one for users and another for organizations, so depending where the cipher is located it can be one or the other, and setting it to zero disables uploading at all. The options are `USER_ATTACHMENT_LIMIT` and `ORG_ATTACHMENT_LIMIT` and they use KB. The commit: https://github.com/dani-garcia/bitwarden_rs/commit/325039c31695ac981da3b88dbbe6c6f40c6a180d
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/vaultwarden#560