mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
Use sas token for attachment downloads (#1153)
* Get limited life attachment download URL This change limits url download to a 1min lifetime. This requires moving to a new container to allow for non-public blob access. Clients will have to call GetAttachmentData api function to receive the download URL. For backwards compatibility, attachment URLs are still present, but will not work for attachments stored in non-public access blobs. * Make GlobalSettings interface for testing * Test LocalAttachmentStorageService equivalence * Remove comment * Add missing globalSettings using * Simplify default attachment container * Default to attachments containe for existing methods A new upload method will be made for uploading to attachments-v2. For compatibility for clients which don't use these new methods, we need to still use the old container. The new container will be used only for new uploads * Remove Default MetaData fixture. * Keep attachments container blob-level security for all instances * Close unclosed FileStream * Favor default value for noop services
This commit is contained in:
@ -2,6 +2,8 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Collections.Generic;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Settings;
|
||||
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Settings;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Settings;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
|
@ -2,6 +2,7 @@
|
||||
using Bit.Core.Models.Table;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Bit.Core.Settings;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
|
@ -5,6 +5,7 @@ using Bit.Core.Models.Table;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Settings;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
|
@ -4,6 +4,7 @@ using System.Linq;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Settings;
|
||||
using Core.Models.Data;
|
||||
|
||||
namespace Bit.Core.Models.Api.Response
|
||||
|
@ -3,6 +3,7 @@ using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Utilities;
|
||||
using Bit.Core.Settings;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
|
@ -3,6 +3,7 @@ using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Utilities;
|
||||
using Bit.Core.Settings;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Settings;
|
||||
using Core.Models.Data;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Utilities;
|
||||
using Bit.Core.Settings;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Core.Settings;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
@ -32,6 +32,12 @@ namespace Bit.Core.Models.Data
|
||||
|
||||
public string FileName { get; set; }
|
||||
public string Key { get; set; }
|
||||
|
||||
public string ContainerName { get; set; } = "attachments";
|
||||
|
||||
// This is stored alongside metadata as an identifier. It does not need repeating in serialization
|
||||
[JsonIgnore]
|
||||
public string AttachmentId { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Context;
|
||||
using Bit.Core.Settings;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
|
@ -42,6 +42,10 @@ namespace Bit.Core.Models.Table
|
||||
try
|
||||
{
|
||||
_attachmentData = JsonConvert.DeserializeObject<Dictionary<string, CipherAttachment.MetaData>>(Attachments);
|
||||
foreach (var kvp in _attachmentData)
|
||||
{
|
||||
kvp.Value.AttachmentId = kvp.Key;
|
||||
}
|
||||
return _attachmentData;
|
||||
}
|
||||
catch
|
||||
|
Reference in New Issue
Block a user