Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2025-03-13 16:57:01 +01:00
Allow disabling attachment uploading
This adds an configuration option to disable uploading attachments in cases where running out of space on server is a concern for example. This was raised in #865 and seems like worthwhile addition.
Dieser Commit ist enthalten in:
Ursprung
8867626de8
Commit
2ea052ba5e
2 geänderte Dateien mit 26 neuen und 4 gelöschten Zeilen
|
@ -631,8 +631,7 @@ fn share_cipher_by_uuid(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/ciphers/<uuid>/attachment", format = "multipart/form-data", data = "<data>")]
|
fn _post_attachment(
|
||||||
fn post_attachment(
|
|
||||||
uuid: String,
|
uuid: String,
|
||||||
data: Data,
|
data: Data,
|
||||||
content_type: &ContentType,
|
content_type: &ContentType,
|
||||||
|
@ -704,6 +703,23 @@ fn post_attachment(
|
||||||
Ok(Json(cipher.to_json(&headers.host, &headers.user.uuid, &conn)))
|
Ok(Json(cipher.to_json(&headers.host, &headers.user.uuid, &conn)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[post("/ciphers/<uuid>/attachment", format = "multipart/form-data", data = "<data>")]
|
||||||
|
fn post_attachment(
|
||||||
|
uuid: String,
|
||||||
|
data: Data,
|
||||||
|
content_type: &ContentType,
|
||||||
|
headers: Headers,
|
||||||
|
conn: DbConn,
|
||||||
|
nt: Notify,
|
||||||
|
) -> JsonResult {
|
||||||
|
if CONFIG.disable_attachments() {
|
||||||
|
err!("Uploading attachments is not allowed on server")
|
||||||
|
}
|
||||||
|
|
||||||
|
_post_attachment(uuid, data, content_type, headers, conn, nt)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#[post("/ciphers/<uuid>/attachment-admin", format = "multipart/form-data", data = "<data>")]
|
#[post("/ciphers/<uuid>/attachment-admin", format = "multipart/form-data", data = "<data>")]
|
||||||
fn post_attachment_admin(
|
fn post_attachment_admin(
|
||||||
uuid: String,
|
uuid: String,
|
||||||
|
@ -713,7 +729,11 @@ fn post_attachment_admin(
|
||||||
conn: DbConn,
|
conn: DbConn,
|
||||||
nt: Notify,
|
nt: Notify,
|
||||||
) -> JsonResult {
|
) -> JsonResult {
|
||||||
post_attachment(uuid, data, content_type, headers, conn, nt)
|
if CONFIG.disable_attachments() {
|
||||||
|
err!("Uploading attachments is not allowed on server")
|
||||||
|
}
|
||||||
|
|
||||||
|
_post_attachment(uuid, data, content_type, headers, conn, nt)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post(
|
#[post(
|
||||||
|
@ -731,7 +751,7 @@ fn post_attachment_share(
|
||||||
nt: Notify,
|
nt: Notify,
|
||||||
) -> JsonResult {
|
) -> JsonResult {
|
||||||
_delete_cipher_attachment_by_id(&uuid, &attachment_id, &headers, &conn, &nt)?;
|
_delete_cipher_attachment_by_id(&uuid, &attachment_id, &headers, &conn, &nt)?;
|
||||||
post_attachment(uuid, data, content_type, headers, conn, nt)
|
_post_attachment(uuid, data, content_type, headers, conn, nt)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/ciphers/<uuid>/attachment/<attachment_id>/delete-admin")]
|
#[post("/ciphers/<uuid>/attachment/<attachment_id>/delete-admin")]
|
||||||
|
|
|
@ -250,6 +250,8 @@ make_config! {
|
||||||
/// $ICON_CACHE_FOLDER, but it won't produce any external network request. Needs to set $ICON_CACHE_TTL to 0,
|
/// $ICON_CACHE_FOLDER, but it won't produce any external network request. Needs to set $ICON_CACHE_TTL to 0,
|
||||||
/// otherwise it will delete them and they won't be downloaded again.
|
/// otherwise it will delete them and they won't be downloaded again.
|
||||||
disable_icon_download: bool, true, def, false;
|
disable_icon_download: bool, true, def, false;
|
||||||
|
/// Disable uploading attachments. |> Set this to true to disable uploading attachments. Already uploaded attachments will continue to work.
|
||||||
|
disable_attachments: bool, true, def, false;
|
||||||
/// Allow new signups |> Controls if new users can register. Note that while this is disabled, users could still be invited
|
/// Allow new signups |> Controls if new users can register. Note that while this is disabled, users could still be invited
|
||||||
signups_allowed: bool, true, def, true;
|
signups_allowed: bool, true, def, true;
|
||||||
/// Require email verification on signups. This will prevent logins from succeeding until the address has been verified
|
/// Require email verification on signups. This will prevent logins from succeeding until the address has been verified
|
||||||
|
|
Laden …
Tabelle hinzufügen
In neuem Issue referenzieren