1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 23:52:50 -05:00

Attachment blob upload (#1229)

* Add Cipher attachment upload endpoints

* Add validation bool to attachment storage data

This bool is used to determine whether or not to renew upload links

* Add model to request a new attachment to be made for later upload

* Add model to respond with created attachment.

The two cipher properties represent the two different
cipher model types that can be returned. Cipher Response from
personal items and mini response from organizations

* Create Azure SAS-authorized upload links for both one-shot and block uploads

* Add service methods to handle delayed upload and file size validation

* Add emergency access method for downloading attachments direct from Azure

* Add new attachment storage methods to other services

* Update service interfaces

* Log event grid exceptions

* Limit Send and Attachment Size to 500MB

* capitalize Key property

* Add key validation to Azure Event Grid endpoint

* Delete blob for unexpected blob creation events

* Set Event Grid key at API startup

* Change renew attachment upload url request path to match Send

* Shore up attachment cleanup method.

As long as we have the required information, we should always delete
attachments from each the Repository, the cipher in memory, and the
file storage service to ensure they're all synched.
This commit is contained in:
Matt Gibson
2021-03-30 18:41:14 -05:00
committed by GitHub
parent 908decac5e
commit 022e404cc5
20 changed files with 556 additions and 114 deletions

View File

@ -0,0 +1,10 @@
namespace Bit.Core.Models.Api
{
public class AttachmentRequestModel
{
public string Key { get; set; }
public string FileName { get; set; }
public long FileSize { get; set; }
public bool AdminRequest { get; set; } = false;
}
}

View File

@ -0,0 +1,15 @@
using Bit.Core.Enums;
namespace Bit.Core.Models.Api
{
public class AttachmentUploadDataResponseModel : ResponseModel
{
public string AttachmentId { get; set; }
public string Url { get; set; }
public FileUploadType FileUploadType { get; set; }
public CipherResponseModel CipherResponse { get; set; }
public CipherMiniResponseModel CipherMiniResponse { get; set; }
public AttachmentUploadDataResponseModel() : base("attachment-fileUpload") { }
}
}

View File

@ -34,6 +34,7 @@ namespace Bit.Core.Models.Data
public string Key { get; set; }
public string ContainerName { get; set; } = "attachments";
public bool Validated { get; set; } = true;
// This is stored alongside metadata as an identifier. It does not need repeating in serialization
[JsonIgnore]