1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 08:02:49 -05:00

Use sas token for send downloads (#1157)

* Remove Url from SendFileModel

Url is now generated on the fly with limited lifetime.

New model houses the download url generated

* Create API endpoint for getting Send file download url

* Generate limited-life Azure download urls

* Lint fix
This commit is contained in:
Matt Gibson
2021-02-24 13:03:16 -06:00
committed by GitHub
parent f8940e4be5
commit e350daeeee
7 changed files with 54 additions and 3 deletions

View File

@ -11,6 +11,7 @@ using Bit.Api.Utilities;
using Bit.Core.Models.Table;
using Bit.Core.Utilities;
using Bit.Core.Settings;
using Bit.Core.Models.Api.Response;
namespace Bit.Api.Controllers
{
@ -21,17 +22,20 @@ namespace Bit.Api.Controllers
private readonly ISendRepository _sendRepository;
private readonly IUserService _userService;
private readonly ISendService _sendService;
private readonly ISendFileStorageService _sendFileStorageService;
private readonly GlobalSettings _globalSettings;
public SendsController(
ISendRepository sendRepository,
IUserService userService,
ISendService sendService,
ISendFileStorageService sendFileStorageService,
GlobalSettings globalSettings)
{
_sendRepository = sendRepository;
_userService = userService;
_sendService = sendService;
_sendFileStorageService = sendFileStorageService;
_globalSettings = globalSettings;
}
@ -59,6 +63,17 @@ namespace Bit.Api.Controllers
return new ObjectResult(new SendAccessResponseModel(send, _globalSettings));
}
[AllowAnonymous]
[HttpGet("access/file/{id}")]
public async Task<SendFileDownloadDataResponseModel> GetSendFileDownloadData(string id)
{
return new SendFileDownloadDataResponseModel()
{
Id = id,
Url = await _sendFileStorageService.GetSendFileDownloadUrlAsync(id),
};
}
[HttpGet("{id}")]
public async Task<SendResponseModel> Get(string id)
{