1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-04 20:50:21 -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:
Matt Gibson 2021-02-22 15:35:16 -06:00 committed by GitHub
parent 78606d5f13
commit 5537470703
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
177 changed files with 694 additions and 178 deletions

View File

@ -1,7 +1,7 @@
using System.Threading.Tasks;
using Bit.Core;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Portal.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

View File

@ -2,10 +2,10 @@
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
using Bit.Core.Services;
using Bit.Core;
using Bit.Core.Models.Data;
using Bit.Core.Enums;
using Bit.Core.Sso;
using Bit.Core.Settings;
using U2F.Core.Utils;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

View File

@ -3,11 +3,11 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text.Json;
using Bit.Core;
using Bit.Core.Enums;
using Bit.Core.Models.Data;
using Bit.Core.Models.Table;
using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Core.Sso;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Mvc.Rendering;

View File

@ -1,5 +1,6 @@
using Bit.Core;
using Bit.Core.Context;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Bit.Portal.Utilities;
using Microsoft.AspNetCore.Builder;

View File

@ -1,4 +1,5 @@
using Bit.Core;
using Bit.Core.Settings;
using Microsoft.AspNetCore.Http;
using System.Threading.Tasks;

View File

@ -1,6 +1,7 @@
using System;
using Bit.Core;
using Bit.Core.Context;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Bit.Sso.Utilities;
using IdentityServer4.Extensions;

View File

@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Bit.Core;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using IdentityServer4.Configuration;
using IdentityServer4.Services;

View File

@ -9,8 +9,8 @@ using Bit.Core.Enums;
using Bit.Core.Models.Data;
using Bit.Core.Models.Table;
using Bit.Core.Repositories;
using Bit.Core.Sso;
using Bit.Core.Utilities;
using Bit.Core.Settings;
using Bit.Sso.Models;
using Bit.Sso.Utilities;
using IdentityModel;

View File

@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using Bit.Core;
using Bit.Core.Business.Sso;
using Bit.Core.IdentityServer;
using Bit.Core.Utilities;
using Bit.Core.Settings;
using Bit.Sso.Models;
using IdentityServer4.Models;
using IdentityServer4.ResponseHandling;

View File

@ -3,7 +3,7 @@ using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Bit.Admin.Models;
using Microsoft.AspNetCore.Authorization;
using Bit.Core;
using Bit.Core.Settings;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;

View File

@ -2,7 +2,7 @@
using System.Linq;
using System.Threading.Tasks;
using Bit.Admin.Models;
using Bit.Core;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

View File

@ -6,9 +6,9 @@ using System.Threading.Tasks;
using Bit.Admin.Models;
using System.Collections.Generic;
using Bit.Core.Models.Table;
using Bit.Core;
using Bit.Core.Utilities;
using Bit.Core.Services;
using Bit.Core.Settings;
namespace Bit.Admin.Controllers
{

View File

@ -9,6 +9,7 @@ using Bit.Core;
using Bit.Core.Models.Table;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;

View File

@ -6,9 +6,9 @@ using System.Threading.Tasks;
using Bit.Admin.Models;
using System.Collections.Generic;
using Bit.Core.Models.Table;
using Bit.Core;
using Bit.Core.Utilities;
using Bit.Core.Services;
using Bit.Core.Settings;
namespace Bit.Admin.Controllers
{

View File

@ -5,7 +5,7 @@ using System.Threading.Tasks;
using Amazon;
using Amazon.SQS;
using Amazon.SQS.Model;
using Bit.Core;
using Bit.Core.Settings;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

View File

@ -2,7 +2,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Bit.Core;
using Bit.Core.Settings;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Azure.Storage.Queues;

View File

@ -4,7 +4,7 @@ using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Bit.Core;
using Bit.Core.Settings;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

View File

@ -2,8 +2,8 @@
using System.Data.SqlClient;
using System.Threading;
using System.Threading.Tasks;
using Bit.Core;
using Bit.Core.Jobs;
using Bit.Core.Settings;
using Bit.Migrator;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

View File

@ -2,6 +2,7 @@
using System.Threading.Tasks;
using Bit.Core;
using Bit.Core.Jobs;
using Bit.Core.Settings;
using Microsoft.Extensions.Logging;
using Quartz;

View File

@ -3,8 +3,8 @@ using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Bit.Core;
using Bit.Core.Jobs;
using Bit.Core.Settings;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Quartz;

View File

@ -1,5 +1,5 @@
using System;
using Bit.Core;
using Bit.Core.Settings;
namespace Bit.Admin.Models
{

View File

@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Bit.Core;
using Bit.Core.Enums;
using Bit.Core.Models.Business;
using Bit.Core.Models.Data;
using Bit.Core.Models.Table;
using Bit.Core.Utilities;
using Bit.Core.Settings;
namespace Bit.Admin.Models
{

View File

@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Bit.Core;
using Bit.Core.Models.Business;
using Bit.Core.Models.Table;
using Bit.Core.Utilities;
using Bit.Core.Settings;
namespace Bit.Admin.Models
{

View File

@ -1,8 +1,8 @@
using System;
using System.Globalization;
using Bit.Core;
using Bit.Core.Context;
using Bit.Core.Identity;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;

View File

@ -1,5 +1,5 @@
@inject SignInManager<IdentityUser> SignInManager
@inject Bit.Core.GlobalSettings GlobalSettings
@inject Bit.Core.Settings.GlobalSettings GlobalSettings
<!DOCTYPE html>
<html>
<head>

View File

@ -9,6 +9,7 @@ using Bit.Core.Models.Data;
using Bit.Core.Models.Table;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

View File

@ -7,12 +7,12 @@ using Microsoft.AspNetCore.Authorization;
using Bit.Core.Models.Api;
using Bit.Core.Exceptions;
using Bit.Core.Services;
using Bit.Core;
using Bit.Core.Context;
using Bit.Api.Utilities;
using Bit.Core.Utilities;
using System.Collections.Generic;
using Bit.Core.Models.Table;
using Bit.Core.Settings;
namespace Bit.Api.Controllers
{
@ -24,6 +24,7 @@ namespace Bit.Api.Controllers
private readonly ICollectionCipherRepository _collectionCipherRepository;
private readonly ICipherService _cipherService;
private readonly IUserService _userService;
private readonly IAttachmentStorageService _attachmentStorageService;
private readonly ICurrentContext _currentContext;
private readonly GlobalSettings _globalSettings;
@ -32,6 +33,7 @@ namespace Bit.Api.Controllers
ICollectionCipherRepository collectionCipherRepository,
ICipherService cipherService,
IUserService userService,
IAttachmentStorageService attachmentStorageService,
ICurrentContext currentContext,
GlobalSettings globalSettings)
{
@ -39,6 +41,7 @@ namespace Bit.Api.Controllers
_collectionCipherRepository = collectionCipherRepository;
_cipherService = cipherService;
_userService = userService;
_attachmentStorageService = attachmentStorageService;
_currentContext = currentContext;
_globalSettings = globalSettings;
}
@ -608,6 +611,27 @@ namespace Bit.Api.Controllers
return new CipherMiniResponseModel(cipher, _globalSettings, cipher.OrganizationUseTotp);
}
[HttpGet("{id}/attachment/{attachmentId}")]
public async Task<AttachmentResponseModel> GetAttachmentData(string id, string attachmentId)
{
var userId = _userService.GetProperUserId(User).Value;
var cipher = await _cipherRepository.GetByIdAsync(new Guid(id), userId);
var attachments = cipher.GetAttachments();
if (!attachments.ContainsKey(attachmentId))
{
throw new NotFoundException();
}
var data = attachments[attachmentId];
var response = new AttachmentResponseModel(attachmentId, data, cipher, _globalSettings)
{
Url = await _attachmentStorageService.GetAttachmentDownloadUrlAsync(cipher, data)
};
return response;
}
[HttpPost("{id}/attachment/{attachmentId}/share")]
[RequestSizeLimit(105_906_176)]
[DisableFormValueModelBinding]

View File

@ -5,12 +5,12 @@ using Microsoft.AspNetCore.Authorization;
using System.Net.Http;
using System.Security.Cryptography;
using Bit.Core.Services;
using Bit.Core;
using Bit.Core.Context;
using System.Net;
using Bit.Core.Exceptions;
using System.Linq;
using Bit.Core.Utilities;
using Bit.Core.Settings;
namespace Bit.Api.Controllers
{

View File

@ -4,7 +4,7 @@ using Bit.Core.Models.Api;
using System.Threading.Tasks;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Authorization;
using Bit.Core;
using Bit.Core.Settings;
using Stripe;
using System.Linq;
using System.Collections.Generic;

View File

@ -8,11 +8,11 @@ using Bit.Core.Enums;
using Bit.Core.Models.Api;
using Bit.Core.Exceptions;
using Bit.Core.Services;
using Bit.Core;
using Bit.Core.Context;
using Bit.Api.Utilities;
using Bit.Core.Models.Business;
using Bit.Core.Utilities;
using Bit.Core.Settings;
namespace Bit.Api.Controllers
{

View File

@ -7,10 +7,10 @@ using Microsoft.AspNetCore.Authorization;
using Bit.Core.Models.Api;
using Bit.Core.Exceptions;
using Bit.Core.Services;
using Bit.Core;
using Bit.Core.Context;
using Bit.Core.Enums;
using Bit.Core.Utilities;
using Bit.Core.Settings;
using Microsoft.AspNetCore.DataProtection;
namespace Bit.Api.Controllers

View File

@ -10,6 +10,7 @@ using System.Linq;
using Microsoft.AspNetCore.Hosting;
using Bit.Api.Utilities;
using Bit.Core.Utilities;
using Bit.Core.Settings;
using Microsoft.Extensions.Hosting;
namespace Bit.Api.Controllers

View File

@ -7,10 +7,10 @@ using Microsoft.AspNetCore.Authorization;
using Bit.Core.Models.Api;
using Bit.Core.Exceptions;
using Bit.Core.Services;
using Bit.Core;
using Bit.Api.Utilities;
using Bit.Core.Models.Table;
using Bit.Core.Utilities;
using Bit.Core.Settings;
namespace Bit.Api.Controllers
{

View File

@ -5,13 +5,13 @@ using Microsoft.AspNetCore.Mvc;
using Bit.Core.Models.Api;
using Bit.Core.Services;
using Bit.Core.Repositories;
using Bit.Core;
using Bit.Core.Enums;
using Bit.Core.Exceptions;
using System.Linq;
using Bit.Core.Models.Table;
using System.Collections.Generic;
using Bit.Core.Models.Data;
using Bit.Core.Settings;
namespace Bit.Api.Controllers
{

View File

@ -9,11 +9,11 @@ using Microsoft.AspNetCore.Identity;
using Bit.Core.Models.Table;
using Bit.Core.Enums;
using System.Linq;
using Bit.Core;
using Bit.Core.Context;
using Bit.Core.Repositories;
using Bit.Core.Utilities;
using Bit.Core.Utilities.Duo;
using Bit.Core.Settings;
namespace Bit.Api.Controllers
{

View File

@ -2,8 +2,8 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Bit.Core;
using Bit.Core.Jobs;
using Bit.Core.Settings;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Quartz;

View File

@ -1,11 +1,11 @@
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Bit.Core;
using Bit.Core.Context;
using Bit.Core.Exceptions;
using Bit.Core.Models.Api.Public;
using Bit.Core.Services;
using Bit.Core.Settings;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

View File

@ -7,6 +7,7 @@ using Bit.Api.Utilities;
using Bit.Core;
using Bit.Core.Context;
using Bit.Core.Identity;
using Bit.Core.Settings;
using Newtonsoft.Json.Serialization;
using AspNetCoreRateLimit;
using Stripe;

View File

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using Bit.Core;
using Bit.Core.Settings;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;

View File

@ -12,7 +12,8 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using Bit.Core;
using Bit.Core.Settings;
namespace Bit.Billing.Controllers
{

View File

@ -1,9 +1,9 @@
using Bit.Core;
using Bit.Core.Enums;
using Bit.Core.Enums;
using Bit.Core.Models.Business;
using Bit.Core.Models.Table;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;

View File

@ -3,8 +3,8 @@ using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Bit.Core;
using Bit.Core.Jobs;
using Bit.Core.Settings;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Quartz;

View File

@ -3,8 +3,8 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Bit.Core;
using Bit.Core.Context;
using Bit.Core.Settings;
using Stripe;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Http;

View File

@ -9,6 +9,7 @@ using System.Threading.Tasks;
using System.Security.Claims;
using Bit.Core.Utilities;
using Bit.Core.Models.Data;
using Bit.Core.Settings;
namespace Bit.Core.Context
{

View File

@ -5,6 +5,7 @@ using System.Threading.Tasks;
using Bit.Core.Enums;
using Bit.Core.Models.Table;
using Bit.Core.Repositories;
using Bit.Core.Settings;
using Microsoft.AspNetCore.Http;
namespace Bit.Core.Context

View File

@ -4,6 +4,7 @@ using System.Threading.Tasks;
using Bit.Core.Enums;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Microsoft.Azure.ServiceBus;
using Microsoft.Azure.ServiceBus.Management;

View File

@ -7,6 +7,7 @@ using Bit.Core.Models;
using System;
using Microsoft.Extensions.DependencyInjection;
using Bit.Core.Services;
using Bit.Core.Settings;
namespace Bit.Core.Identity
{

View File

@ -3,6 +3,7 @@ using Bit.Core.Models.Table;
using Bit.Core.Enums;
using Bit.Core.Utilities.Duo;
using Bit.Core.Models;
using Bit.Core.Settings;
namespace Bit.Core.Identity
{

View File

@ -13,6 +13,7 @@ using U2F.Core.Exceptions;
using U2F.Core.Utils;
using System;
using Bit.Core.Services;
using Bit.Core.Settings;
using Microsoft.Extensions.DependencyInjection;
namespace Bit.Core.Identity

View File

@ -6,6 +6,7 @@ using Bit.Core.Models.Table;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Bit.Core.Context;
using Bit.Core.Settings;
using Microsoft.Extensions.DependencyInjection;
namespace Bit.Core.Identity

View File

@ -5,6 +5,7 @@ using Bit.Core.Enums;
using YubicoDotNetClient;
using System.Linq;
using Bit.Core.Services;
using Bit.Core.Settings;
using System;
using Microsoft.Extensions.DependencyInjection;

View File

@ -1,6 +1,7 @@
using IdentityServer4.Models;
using System.Collections.Generic;
using System.Linq;
using Bit.Core.Settings;
namespace Bit.Core.IdentityServer
{

View File

@ -18,6 +18,7 @@ using System.Reflection;
using Microsoft.Extensions.Logging;
using Bit.Core.Models.Api;
using Bit.Core.Context;
using Bit.Core.Settings;
namespace Bit.Core.IdentityServer
{

View File

@ -9,6 +9,7 @@ using IdentityModel;
using Bit.Core.Utilities;
using System.Security.Claims;
using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Core.Context;
using System.Collections.ObjectModel;

View File

@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Caching.Redis;
using Microsoft.Extensions.Options;
using Bit.Core.Settings;
namespace Bit.Core.IdentityServer
{

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Security.Claims;
using System.Threading.Tasks;
using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Core.Context;
using System.Linq;
using Bit.Core.Identity;

View File

@ -1,6 +1,7 @@
using IdentityServer4;
using IdentityServer4.Models;
using System.Collections.Generic;
using Bit.Core.Settings;
namespace Bit.Core.IdentityServer
{

View File

@ -10,6 +10,7 @@ using System;
using IdentityModel;
using Bit.Core.Utilities;
using Bit.Core.Context;
using Bit.Core.Settings;
namespace Bit.Core.IdentityServer
{

View File

@ -9,6 +9,7 @@ using System.Threading.Tasks;
using Bit.Core.Services;
using Bit.Core.Identity;
using Bit.Core.Context;
using Bit.Core.Settings;
using Microsoft.Extensions.Logging;
namespace Bit.Core.IdentityServer

View File

@ -1,6 +1,7 @@
using IdentityServer4.Models;
using System.Collections.Generic;
using System.Linq;
using Bit.Core.Settings;
namespace Bit.Core.IdentityServer
{

View File

@ -1,6 +1,7 @@
using Bit.Core.Utilities;
using IdentityServer4.Services;
using System.Threading.Tasks;
using Bit.Core.Settings;
namespace Bit.Core.IdentityServer
{

View File

@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging;
using Quartz;
using Quartz.Impl;
using Quartz.Impl.Matchers;
using Bit.Core.Settings;
namespace Bit.Core.Jobs
{

View File

@ -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
{

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Bit.Core.Settings;
namespace Bit.Core.Models.Api
{

View File

@ -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

View File

@ -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
{

View File

@ -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
{

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,5 +1,6 @@
using Bit.Core.Models.Data;
using Bit.Core.Utilities;
using Bit.Core.Settings;
namespace Bit.Core.Models.Api
{

View File

@ -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;

View File

@ -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; }
}
}
}

View File

@ -1,6 +1,7 @@
using System;
using Bit.Core.Enums;
using Bit.Core.Context;
using Bit.Core.Settings;
namespace Bit.Core.Models.Data
{

View File

@ -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

View File

@ -5,6 +5,7 @@ using System.Linq;
using System.Threading.Tasks;
using Bit.Core.Models.Data;
using Bit.Core.Models.Table;
using Bit.Core.Settings;
using Dapper;
using Npgsql;

View File

@ -10,6 +10,7 @@ using Core.Models.Data;
using Bit.Core.Utilities;
using Newtonsoft.Json;
using Bit.Core.Models.Data;
using Bit.Core.Settings;
namespace Bit.Core.Repositories.SqlServer
{

View File

@ -7,6 +7,7 @@ using System.Data;
using Dapper;
using System.Linq;
using Bit.Core.Utilities;
using Bit.Core.Settings;
namespace Bit.Core.Repositories.SqlServer
{

View File

@ -9,6 +9,7 @@ using System.Linq;
using Newtonsoft.Json;
using Bit.Core.Utilities;
using Bit.Core.Models.Data;
using Bit.Core.Settings;
namespace Bit.Core.Repositories.SqlServer
{

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Data.SqlClient;
using System.Threading.Tasks;
using Bit.Core.Models.Table;
using Bit.Core.Settings;
using System.Data;
using Dapper;

View File

@ -7,6 +7,7 @@ using Dapper;
using System.Linq;
using System.Collections.Generic;
using Bit.Core.Models.Data;
using Bit.Core.Settings;
namespace Bit.Core.Repositories.SqlServer
{

View File

@ -3,6 +3,7 @@ using Bit.Core.Models.Table;
using System.Threading.Tasks;
using System.Collections.Generic;
using Bit.Core.Models.Data;
using Bit.Core.Settings;
using System.Data.SqlClient;
using System.Linq;
using System.Data;

View File

@ -1,5 +1,6 @@
using System;
using Bit.Core.Models.Table;
using Bit.Core.Settings;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Data;

View File

@ -4,6 +4,7 @@ using System.Data.SqlClient;
using System.Linq;
using System.Threading.Tasks;
using Bit.Core.Models.Table;
using Bit.Core.Settings;
using Dapper;
namespace Bit.Core.Repositories.SqlServer

View File

@ -9,6 +9,7 @@ using System.Linq;
using Newtonsoft.Json;
using Bit.Core.Utilities;
using Bit.Core.Models.Data;
using Bit.Core.Settings;
namespace Bit.Core.Repositories.SqlServer
{

View File

@ -1,5 +1,6 @@
using System;
using Bit.Core.Models.Table;
using Bit.Core.Settings;
namespace Bit.Core.Repositories.SqlServer
{

View File

@ -2,6 +2,7 @@
using System.Data.SqlClient;
using System.Threading.Tasks;
using Dapper;
using Bit.Core.Settings;
namespace Bit.Core.Repositories.SqlServer
{

View File

@ -7,6 +7,7 @@ using Dapper;
using System.Linq;
using System.Collections.Generic;
using Bit.Core.Models.Data;
using Bit.Core.Settings;
namespace Bit.Core.Repositories.SqlServer
{

View File

@ -9,6 +9,7 @@ using Bit.Core.Models.Data;
using System.Collections.Generic;
using Bit.Core.Enums;
using Bit.Core.Utilities;
using Bit.Core.Settings;
using Newtonsoft.Json;
namespace Bit.Core.Repositories.SqlServer

View File

@ -7,6 +7,7 @@ using System.Data;
using Dapper;
using System.Linq;
using Bit.Core.Enums;
using Bit.Core.Settings;
namespace Bit.Core.Repositories.SqlServer
{

View File

@ -1,5 +1,6 @@
using System;
using Bit.Core.Models.Table;
using Bit.Core.Settings;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Data;

View File

@ -1,5 +1,6 @@
using System;
using Bit.Core.Models.Table;
using Bit.Core.Settings;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;

View File

@ -1,4 +1,5 @@
using Bit.Core.Models.Table;
using Bit.Core.Settings;
using Dapper;
using System;
using System.Threading.Tasks;

View File

@ -1,4 +1,5 @@
using Bit.Core.Models.Table;
using Bit.Core.Settings;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Data;

View File

@ -7,6 +7,7 @@ using System.Data;
using System.Data.SqlClient;
using System.Linq;
using Bit.Core.Enums;
using Bit.Core.Settings;
namespace Bit.Core.Repositories.SqlServer
{

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Data.SqlClient;
using System.Threading.Tasks;
using Bit.Core.Models.Table;
using Bit.Core.Settings;
using System.Data;
using Dapper;

View File

@ -6,6 +6,7 @@ using System.Linq;
using System.Threading.Tasks;
using Bit.Core.Models.Data;
using Bit.Core.Models.Table;
using Bit.Core.Settings;
using Dapper;
namespace Bit.Core.Repositories.SqlServer

View File

@ -6,6 +6,7 @@ using Bit.Core.Models.Data;
using Bit.Core.Models.Table;
using Bit.Core.Utilities;
using Microsoft.Azure.Cosmos.Table;
using Bit.Core.Settings;
namespace Bit.Core.Repositories.TableStorage
{

View File

@ -3,6 +3,7 @@ using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Bit.Core.Models.Data;
using Bit.Core.Settings;
using Microsoft.Azure.Cosmos.Table;
namespace Bit.Core.Repositories.TableStorage

Some files were not shown because too many files have changed in this diff Show More