mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-08-03 17:49:07 +00:00
Add some extra access checks for attachments and groups
This commit is contained in:
parent
e7f083dee9
commit
60964c07e6
7 changed files with 101 additions and 28 deletions
|
@ -934,6 +934,15 @@ async fn share_cipher_by_uuid(
|
|||
/// redirects to the same location as before the v2 API.
|
||||
#[get("/ciphers/<uuid>/attachment/<attachment_id>")]
|
||||
async fn get_attachment(uuid: &str, attachment_id: &str, headers: Headers, mut conn: DbConn) -> JsonResult {
|
||||
let cipher = match Cipher::find_by_uuid(uuid, &mut conn).await {
|
||||
Some(cipher) => cipher,
|
||||
None => err!("Cipher doesn't exist"),
|
||||
};
|
||||
|
||||
if !cipher.is_accessible_to_user(&headers.user.uuid, &mut conn).await {
|
||||
err!("Cipher is not accessible")
|
||||
}
|
||||
|
||||
match Attachment::find_by_id(attachment_id, &mut conn).await {
|
||||
Some(attachment) if uuid == attachment.cipher_uuid => Ok(Json(attachment.to_json(&headers.host))),
|
||||
Some(_) => err!("Attachment doesn't belong to cipher"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue