From 8c7f1dd343112f1a59180e3403a91378cc160377 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 27 Feb 2017 22:58:01 -0500 Subject: [PATCH] Support for CipherKey and Share APIs --- src/Api/Controllers/LoginsController.cs | 19 ++++++++-------- src/Api/Controllers/SharesController.cs | 14 ++++++++++++ .../Models/Response/CipherResponseModel.cs | 11 ++++------ .../Models/Response/FolderResponseModel.cs | 4 ---- src/Api/Models/Response/LoginResponseModel.cs | 22 ++++++++++++++----- src/Api/Models/Response/ShareResponseModel.cs | 7 ++---- src/Api/Startup.cs | 1 + src/Core/Domains/Cipher.cs | 1 + src/Core/Domains/Share.cs | 2 +- src/Core/Enums/SharePermissionType.cs | 8 ------- src/Core/Models/Data/CipherShare.cs | 3 +-- src/Core/Repositories/ICipherRepository.cs | 1 + src/Core/Repositories/IShareRepository.cs | 2 ++ .../SqlServer/CipherRepository.cs | 17 ++++++++++++++ .../Repositories/SqlServer/ShareRepository.cs | 18 +++++++++++++++ .../Services/Implementations/CipherService.cs | 2 +- src/Sql/Sql.sqlproj | 2 ++ .../CipherShare_ReadByTypeUserId.sql | 15 +++++++++++++ .../CipherShare_ReadByUserId.sql | 1 + .../dbo/Stored Procedures/Cipher_Create.sql | 3 +++ .../dbo/Stored Procedures/Cipher_Update.sql | 2 ++ .../dbo/Stored Procedures/Share_Create.sql | 6 ++--- .../Share_ReadByCipherId.sql | 13 +++++++++++ .../dbo/Stored Procedures/Share_Update.sql | 4 ++-- src/Sql/dbo/Tables/Cipher.sql | 1 + src/Sql/dbo/Tables/Share.sql | 2 +- src/Sql/dbo/Views/CipherShareView.sql | 16 ++++++++++---- 27 files changed, 144 insertions(+), 53 deletions(-) delete mode 100644 src/Core/Enums/SharePermissionType.cs create mode 100644 src/Sql/dbo/Stored Procedures/CipherShare_ReadByTypeUserId.sql create mode 100644 src/Sql/dbo/Stored Procedures/Share_ReadByCipherId.sql diff --git a/src/Api/Controllers/LoginsController.cs b/src/Api/Controllers/LoginsController.cs index e702aed80b..da377bab6a 100644 --- a/src/Api/Controllers/LoginsController.cs +++ b/src/Api/Controllers/LoginsController.cs @@ -8,7 +8,6 @@ using Microsoft.AspNetCore.Authorization; using Bit.Api.Models; using Bit.Core.Exceptions; using Bit.Core.Domains; -using Microsoft.AspNetCore.Identity; using Bit.Core.Services; namespace Bit.Api.Controllers @@ -34,29 +33,29 @@ namespace Bit.Api.Controllers } [HttpGet("{id}")] - public async Task Get(string id, string[] expand = null) + public async Task Get(string id, string[] expand = null) { var userId = _userService.GetProperUserId(User).Value; - var login = await _cipherRepository.GetByIdAsync(new Guid(id), userId); + var login = await _cipherRepository.GetShareByIdAsync(new Guid(id), userId); if(login == null || login.Type != Core.Enums.CipherType.Login) { throw new NotFoundException(); } - var response = new LoginResponseModel(login, userId); + var response = new LoginShareResponseModel(login, userId); await ExpandAsync(login, response, expand, null, userId); return response; } [HttpGet("")] - public async Task> Get(string[] expand = null) + public async Task> Get(string[] expand = null) { var userId = _userService.GetProperUserId(User).Value; - ICollection logins = await _cipherRepository.GetManyByTypeAndUserIdAsync(Core.Enums.CipherType.Login, + var logins = await _cipherRepository.GetManyShareByTypeAndUserIdAsync(Core.Enums.CipherType.Login, userId); - var responses = logins.Select(s => new LoginResponseModel(s, userId)).ToList(); + var responses = logins.Select(s => new LoginShareResponseModel(s, userId)).ToList(); await ExpandManyAsync(logins, responses, expand, null, userId); - return new ListResponseModel(responses); + return new ListResponseModel(responses); } [HttpPost("")] @@ -120,8 +119,8 @@ namespace Bit.Api.Controllers } } - private async Task ExpandManyAsync(IEnumerable logins, ICollection responses, - string[] expand, IEnumerable folders, Guid userId) + private async Task ExpandManyAsync(IEnumerable logins, ICollection responses, + string[] expand, IEnumerable folders, Guid userId) where TResponseModel : LoginResponseModel { if(expand == null || expand.Count() == 0) { diff --git a/src/Api/Controllers/SharesController.cs b/src/Api/Controllers/SharesController.cs index 31448b6df3..9960179810 100644 --- a/src/Api/Controllers/SharesController.cs +++ b/src/Api/Controllers/SharesController.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Authorization; using Bit.Api.Models; using Bit.Core.Exceptions; using Bit.Core.Services; +using System.Collections.Generic; namespace Bit.Api.Controllers { @@ -41,6 +42,19 @@ namespace Bit.Api.Controllers return new ShareResponseModel(share); } + //[HttpGet("cipher/{cipherId}")] + //public async Task> GetCipher(string cipherId) + //{ + // var userId = _userService.GetProperUserId(User).Value; + // var share = await _shareRepository.GetByIdAsync(new Guid(cipherId), userId); + // if(share == null) + // { + // throw new NotFoundException(); + // } + + // return new ShareResponseModel(share); + //} + [HttpPost("")] public async Task Post([FromBody]ShareRequestModel model) { diff --git a/src/Api/Models/Response/CipherResponseModel.cs b/src/Api/Models/Response/CipherResponseModel.cs index ff3ee59dfb..522340dd81 100644 --- a/src/Api/Models/Response/CipherResponseModel.cs +++ b/src/Api/Models/Response/CipherResponseModel.cs @@ -1,8 +1,6 @@ using System; using Bit.Core.Domains; using Bit.Core.Models.Data; -using System.Collections.Generic; -using Newtonsoft.Json; namespace Bit.Api.Models { @@ -21,6 +19,7 @@ namespace Bit.Api.Models Type = cipher.Type; Favorite = cipher.Favorite; RevisionDate = cipher.RevisionDate; + Key = cipher.Key; switch(cipher.Type) { @@ -39,6 +38,7 @@ namespace Bit.Api.Models public string FolderId { get; set; } public Core.Enums.CipherType Type { get; set; } public bool Favorite { get; set; } + public string Key { get; set; } public dynamic Data { get; set; } public DateTime RevisionDate { get; set; } } @@ -48,14 +48,11 @@ namespace Bit.Api.Models public CipherShareResponseModel(CipherShare cipherShare, Guid userId) : base(cipherShare, userId, "cipherShare") { - Key = cipherShare.Key; - Permissions = cipherShare.Permissions == null ? null : - JsonConvert.DeserializeObject>(cipherShare.Permissions); + ReadOnly = cipherShare.ReadOnly; Status = cipherShare.Status; } - public string Key { get; set; } - public IEnumerable Permissions { get; set; } + public bool ReadOnly { get; set; } public Core.Enums.ShareStatusType? Status { get; set; } } } diff --git a/src/Api/Models/Response/FolderResponseModel.cs b/src/Api/Models/Response/FolderResponseModel.cs index ccc988610b..a9620a7477 100644 --- a/src/Api/Models/Response/FolderResponseModel.cs +++ b/src/Api/Models/Response/FolderResponseModel.cs @@ -1,8 +1,5 @@ using System; using Bit.Core.Domains; -using Newtonsoft.Json; -using System.Collections.Generic; -using System.Linq; namespace Bit.Api.Models { @@ -30,7 +27,6 @@ namespace Bit.Api.Models public string Id { get; set; } public string Name { get; set; } - public string Key { get; set; } public DateTime RevisionDate { get; set; } } } diff --git a/src/Api/Models/Response/LoginResponseModel.cs b/src/Api/Models/Response/LoginResponseModel.cs index 2f097a9234..924cd62168 100644 --- a/src/Api/Models/Response/LoginResponseModel.cs +++ b/src/Api/Models/Response/LoginResponseModel.cs @@ -1,14 +1,12 @@ using System; using Bit.Core.Domains; -using Newtonsoft.Json; -using System.Collections.Generic; -using System.Linq; +using Bit.Core.Models.Data; namespace Bit.Api.Models { public class LoginResponseModel : ResponseModel { - public LoginResponseModel(Cipher cipher, Guid userId) + public LoginResponseModel(Cipher cipher, Guid userId, string obj = "login") : base("login") { if(cipher == null) @@ -32,6 +30,7 @@ namespace Bit.Api.Models Password = data.Password; Notes = data.Notes; RevisionDate = cipher.RevisionDate; + Key = cipher.Key; } public string Id { get; set; } @@ -42,10 +41,23 @@ namespace Bit.Api.Models public string Username { get; set; } public string Password { get; set; } public string Notes { get; set; } - public string Key { get; set; } public DateTime RevisionDate { get; set; } + public string Key { get; set; } // Expandables public FolderResponseModel Folder { get; set; } } + + public class LoginShareResponseModel : LoginResponseModel + { + public LoginShareResponseModel(CipherShare cipherShare, Guid userId) + : base(cipherShare, userId, "loginShare") + { + ReadOnly = cipherShare.ReadOnly; + Status = cipherShare.Status; + } + + public bool ReadOnly { get; set; } + public Core.Enums.ShareStatusType? Status { get; set; } + } } diff --git a/src/Api/Models/Response/ShareResponseModel.cs b/src/Api/Models/Response/ShareResponseModel.cs index 452d8f5989..740fa1b60c 100644 --- a/src/Api/Models/Response/ShareResponseModel.cs +++ b/src/Api/Models/Response/ShareResponseModel.cs @@ -1,7 +1,5 @@ using System; using Bit.Core.Domains; -using System.Collections.Generic; -using Newtonsoft.Json; namespace Bit.Api.Models { @@ -20,8 +18,7 @@ namespace Bit.Api.Models SharerUserId = share.SharerUserId.ToString(); CipherId = share.CipherId.ToString(); Key = Key; - Permissions = share.Permissions == null ? null : - JsonConvert.DeserializeObject>(share.Permissions); + ReadOnly = share.ReadOnly; Status = share.Status; } @@ -30,7 +27,7 @@ namespace Bit.Api.Models public string SharerUserId { get; set; } public string CipherId { get; set; } public string Key { get; set; } - public IEnumerable Permissions { get; set; } + public bool ReadOnly { get; set; } public Core.Enums.ShareStatusType? Status { get; set; } } } diff --git a/src/Api/Startup.cs b/src/Api/Startup.cs index 9b68be85e9..cc91f10d3a 100644 --- a/src/Api/Startup.cs +++ b/src/Api/Startup.cs @@ -79,6 +79,7 @@ namespace Bit.Api services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); // Context services.AddScoped(); diff --git a/src/Core/Domains/Cipher.cs b/src/Core/Domains/Cipher.cs index 46accfb29d..fcfb740fe8 100644 --- a/src/Core/Domains/Cipher.cs +++ b/src/Core/Domains/Cipher.cs @@ -10,6 +10,7 @@ namespace Bit.Core.Domains public Guid? FolderId { get; set; } public Enums.CipherType Type { get; set; } public bool Favorite { get; set; } + public string Key { get; set; } public string Data { get; set; } public DateTime CreationDate { get; internal set; } = DateTime.UtcNow; public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow; diff --git a/src/Core/Domains/Share.cs b/src/Core/Domains/Share.cs index 2f5cae7355..96c2e7252d 100644 --- a/src/Core/Domains/Share.cs +++ b/src/Core/Domains/Share.cs @@ -10,7 +10,7 @@ namespace Bit.Core.Domains public Guid SharerUserId { get; set; } public Guid CipherId { get; set; } public string Key { get; set; } - public string Permissions { get; set; } + public bool ReadOnly { get; set; } public Enums.ShareStatusType Status { get; set; } public DateTime CreationDate { get; internal set; } = DateTime.UtcNow; public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow; diff --git a/src/Core/Enums/SharePermissionType.cs b/src/Core/Enums/SharePermissionType.cs deleted file mode 100644 index 72f9a02403..0000000000 --- a/src/Core/Enums/SharePermissionType.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Bit.Core.Enums -{ - public enum SharePermissionType : byte - { - Reshare = 0, - Edit = 1 - } -} diff --git a/src/Core/Models/Data/CipherShare.cs b/src/Core/Models/Data/CipherShare.cs index a7150aa198..af324a5b74 100644 --- a/src/Core/Models/Data/CipherShare.cs +++ b/src/Core/Models/Data/CipherShare.cs @@ -4,8 +4,7 @@ namespace Bit.Core.Models.Data { public class CipherShare : Cipher { - public string Key { get; internal set; } - public string Permissions { get; internal set; } + public bool ReadOnly { get; internal set; } public Enums.ShareStatusType? Status { get; internal set; } } } diff --git a/src/Core/Repositories/ICipherRepository.cs b/src/Core/Repositories/ICipherRepository.cs index 8978c26dd2..887c3ed6ba 100644 --- a/src/Core/Repositories/ICipherRepository.cs +++ b/src/Core/Repositories/ICipherRepository.cs @@ -13,6 +13,7 @@ namespace Bit.Core.Repositories Task> GetManyByUserIdAsync(Guid userId); Task> GetManyShareByUserIdAsync(Guid userId); Task> GetManyByTypeAndUserIdAsync(Enums.CipherType type, Guid userId); + Task> GetManyShareByTypeAndUserIdAsync(Enums.CipherType type, Guid userId); Task, ICollection>> GetManySinceRevisionDateAndUserIdWithDeleteHistoryAsync(DateTime sinceRevisionDate, Guid userId); Task UpdateUserEmailPasswordAndCiphersAsync(User user, IEnumerable ciphers); diff --git a/src/Core/Repositories/IShareRepository.cs b/src/Core/Repositories/IShareRepository.cs index beadfe5fa3..570ce2a920 100644 --- a/src/Core/Repositories/IShareRepository.cs +++ b/src/Core/Repositories/IShareRepository.cs @@ -1,11 +1,13 @@ using System; using Bit.Core.Domains; using System.Threading.Tasks; +using System.Collections.Generic; namespace Bit.Core.Repositories { public interface IShareRepository : IRepository { Task GetByIdAsync(Guid id, Guid userId); + Task> GetManyByCipherId(Guid id); } } diff --git a/src/Core/Repositories/SqlServer/CipherRepository.cs b/src/Core/Repositories/SqlServer/CipherRepository.cs index cbca04c6bd..4b0506ae2b 100644 --- a/src/Core/Repositories/SqlServer/CipherRepository.cs +++ b/src/Core/Repositories/SqlServer/CipherRepository.cs @@ -88,6 +88,23 @@ namespace Bit.Core.Repositories.SqlServer } } + public async Task> GetManyShareByTypeAndUserIdAsync(Enums.CipherType type, Guid userId) + { + using(var connection = new SqlConnection(ConnectionString)) + { + var results = await connection.QueryAsync( + $"[{Schema}].[CipherShare_ReadByTypeUserId]", + new + { + Type = type, + UserId = userId + }, + commandType: CommandType.StoredProcedure); + + return results.ToList(); + } + } + public async Task, ICollection>> GetManySinceRevisionDateAndUserIdWithDeleteHistoryAsync(DateTime sinceRevisionDate, Guid userId) { diff --git a/src/Core/Repositories/SqlServer/ShareRepository.cs b/src/Core/Repositories/SqlServer/ShareRepository.cs index 32c640a5b7..2a461b9eda 100644 --- a/src/Core/Repositories/SqlServer/ShareRepository.cs +++ b/src/Core/Repositories/SqlServer/ShareRepository.cs @@ -1,6 +1,11 @@ using System; using Bit.Core.Domains; using System.Threading.Tasks; +using System.Collections.Generic; +using System.Data.SqlClient; +using Dapper; +using System.Data; +using System.Linq; namespace Bit.Core.Repositories.SqlServer { @@ -24,5 +29,18 @@ namespace Bit.Core.Repositories.SqlServer return share; } + + public async Task> GetManyByCipherId(Guid cipherId) + { + using(var connection = new SqlConnection(ConnectionString)) + { + var results = await connection.QueryAsync( + $"[{Schema}].[Share_ReadByCipherId]", + new { CipherId = cipherId }, + commandType: CommandType.StoredProcedure); + + return results.ToList(); + } + } } } diff --git a/src/Core/Services/Implementations/CipherService.cs b/src/Core/Services/Implementations/CipherService.cs index 3d172ff01f..5d58e425bf 100644 --- a/src/Core/Services/Implementations/CipherService.cs +++ b/src/Core/Services/Implementations/CipherService.cs @@ -104,7 +104,7 @@ namespace Bit.Core.Services share.UserId = user.Id; // TODO: Permissions and status - share.Permissions = null; + share.ReadOnly = false; share.Status = Enums.ShareStatusType.Accepted; await _shareRepository.CreateAsync(share); diff --git a/src/Sql/Sql.sqlproj b/src/Sql/Sql.sqlproj index c7659a12a6..20bcbfbf2f 100644 --- a/src/Sql/Sql.sqlproj +++ b/src/Sql/Sql.sqlproj @@ -112,5 +112,7 @@ + + \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/CipherShare_ReadByTypeUserId.sql b/src/Sql/dbo/Stored Procedures/CipherShare_ReadByTypeUserId.sql new file mode 100644 index 0000000000..e77f7f15b1 --- /dev/null +++ b/src/Sql/dbo/Stored Procedures/CipherShare_ReadByTypeUserId.sql @@ -0,0 +1,15 @@ +CREATE PROCEDURE [dbo].[CipherShare_ReadByTypeUserId] + @Type TINYINT, + @UserId UNIQUEIDENTIFIER +AS +BEGIN + SET NOCOUNT ON + + SELECT + * + FROM + [dbo].[CipherView] + WHERE + [Type] = @Type + AND [UserId] = @UserId +END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/CipherShare_ReadByUserId.sql b/src/Sql/dbo/Stored Procedures/CipherShare_ReadByUserId.sql index 46bebd21d2..77be9d1f4b 100644 --- a/src/Sql/dbo/Stored Procedures/CipherShare_ReadByUserId.sql +++ b/src/Sql/dbo/Stored Procedures/CipherShare_ReadByUserId.sql @@ -10,4 +10,5 @@ BEGIN [dbo].[CipherShareView] WHERE [UserId] = @UserId + OR [ShareUserId] = @UserId END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/Cipher_Create.sql b/src/Sql/dbo/Stored Procedures/Cipher_Create.sql index 3eef16597f..48d5e8fe5e 100644 --- a/src/Sql/dbo/Stored Procedures/Cipher_Create.sql +++ b/src/Sql/dbo/Stored Procedures/Cipher_Create.sql @@ -4,6 +4,7 @@ @FolderId UNIQUEIDENTIFIER, @Type TINYINT, @Favorite BIT, + @Key NVARCHAR(MAX), @Data NVARCHAR(MAX), @CreationDate DATETIME2(7), @RevisionDate DATETIME2(7) @@ -18,6 +19,7 @@ BEGIN [FolderId], [Type], [Favorite], + [Key], [Data], [CreationDate], [RevisionDate] @@ -29,6 +31,7 @@ BEGIN @FolderId, @Type, @Favorite, + @Key, @Data, @CreationDate, @RevisionDate diff --git a/src/Sql/dbo/Stored Procedures/Cipher_Update.sql b/src/Sql/dbo/Stored Procedures/Cipher_Update.sql index ff3d23ae91..e8e02332e8 100644 --- a/src/Sql/dbo/Stored Procedures/Cipher_Update.sql +++ b/src/Sql/dbo/Stored Procedures/Cipher_Update.sql @@ -4,6 +4,7 @@ @FolderId UNIQUEIDENTIFIER, @Type TINYINT, @Favorite BIT, + @Key NVARCHAR(MAX), @Data NVARCHAR(MAX), @CreationDate DATETIME2(7), @RevisionDate DATETIME2(7) @@ -18,6 +19,7 @@ BEGIN [FolderId] = @FolderId, [Type] = @Type, [Favorite] = @Favorite, + [Key] = @Key, [Data] = @Data, [CreationDate] = @CreationDate, [RevisionDate] = @RevisionDate diff --git a/src/Sql/dbo/Stored Procedures/Share_Create.sql b/src/Sql/dbo/Stored Procedures/Share_Create.sql index 35981eb2b6..e5bb141fc3 100644 --- a/src/Sql/dbo/Stored Procedures/Share_Create.sql +++ b/src/Sql/dbo/Stored Procedures/Share_Create.sql @@ -4,7 +4,7 @@ @SharerUserId UNIQUEIDENTIFIER, @CipherId UNIQUEIDENTIFIER, @Key NVARCHAR(MAX), - @Permissions NVARCHAR(MAX), + @ReadOnly BIT, @Status TINYINT, @CreationDate DATETIME2(7), @RevisionDate DATETIME2(7) @@ -19,7 +19,7 @@ BEGIN [SharerUserId], [CipherId], [Key], - [Permissions], + [ReadOnly], [Status], [CreationDate], [RevisionDate] @@ -31,7 +31,7 @@ BEGIN @SharerUserId, @CipherId, @Key, - @Permissions, + @ReadOnly, @Status, @CreationDate, @RevisionDate diff --git a/src/Sql/dbo/Stored Procedures/Share_ReadByCipherId.sql b/src/Sql/dbo/Stored Procedures/Share_ReadByCipherId.sql new file mode 100644 index 0000000000..6fde153a1c --- /dev/null +++ b/src/Sql/dbo/Stored Procedures/Share_ReadByCipherId.sql @@ -0,0 +1,13 @@ +CREATE PROCEDURE [dbo].[Share_ReadByCipherId] + @CipherId UNIQUEIDENTIFIER +AS +BEGIN + SET NOCOUNT ON + + SELECT + * + FROM + [dbo].[ShareView] + WHERE + [CipherId] = @CipherId +END diff --git a/src/Sql/dbo/Stored Procedures/Share_Update.sql b/src/Sql/dbo/Stored Procedures/Share_Update.sql index 1369d80957..d1baffc0c8 100644 --- a/src/Sql/dbo/Stored Procedures/Share_Update.sql +++ b/src/Sql/dbo/Stored Procedures/Share_Update.sql @@ -4,7 +4,7 @@ @SharerUserId UNIQUEIDENTIFIER, @CipherId UNIQUEIDENTIFIER, @Key NVARCHAR(MAX), - @Permissions NVARCHAR(MAX), + @ReadOnly BIT, @Status TINYINT, @CreationDate DATETIME2(7), @RevisionDate DATETIME2(7) @@ -19,7 +19,7 @@ BEGIN [SharerUserId] = @SharerUserId, [CipherId] = @CipherId, [Key] = @Key, - [Permissions] = @Permissions, + [ReadOnly] = @ReadOnly, [Status] = @Status, [CreationDate] = @CreationDate, [RevisionDate] = @RevisionDate diff --git a/src/Sql/dbo/Tables/Cipher.sql b/src/Sql/dbo/Tables/Cipher.sql index 719e147b09..767bf879d8 100644 --- a/src/Sql/dbo/Tables/Cipher.sql +++ b/src/Sql/dbo/Tables/Cipher.sql @@ -4,6 +4,7 @@ [FolderId] UNIQUEIDENTIFIER NULL, [Type] TINYINT NOT NULL, [Favorite] BIT NOT NULL, + [Key] NVARCHAR (MAX) NULL, [Data] NVARCHAR (MAX) NOT NULL, [CreationDate] DATETIME2 (7) NOT NULL, [RevisionDate] DATETIME2 (7) NOT NULL, diff --git a/src/Sql/dbo/Tables/Share.sql b/src/Sql/dbo/Tables/Share.sql index d5d02a563c..4072272758 100644 --- a/src/Sql/dbo/Tables/Share.sql +++ b/src/Sql/dbo/Tables/Share.sql @@ -4,7 +4,7 @@ [SharerUserId] UNIQUEIDENTIFIER NOT NULL, [CipherId] UNIQUEIDENTIFIER NOT NULL, [Key] VARCHAR (MAX) NULL, - [Permissions] VARCHAR (MAX) NULL, + [ReadOnly] BIT NOT NULL, [Status] TINYINT NOT NULL, [CreationDate] DATETIME2 (7) NOT NULL, [RevisionDate] DATETIME2 (7) NOT NULL, diff --git a/src/Sql/dbo/Views/CipherShareView.sql b/src/Sql/dbo/Views/CipherShareView.sql index 9e7ce4cb02..86b5404388 100644 --- a/src/Sql/dbo/Views/CipherShareView.sql +++ b/src/Sql/dbo/Views/CipherShareView.sql @@ -1,10 +1,18 @@ CREATE VIEW [dbo].[CipherShareView] AS SELECT - C.*, - S.[Key], - S.[Permissions], - S.[Status] + C.[Id], + C.[UserId], + C.[FolderId], + C.[Type], + C.[Favorite], + ISNULL(S.[Key], C.[Key]) [Key], + C.[Data], + C.[CreationDate], + C.[RevisionDate], + S.[ReadOnly], + S.[Status], + S.[UserId] [ShareUserId] FROM [dbo].[Cipher] C LEFT JOIN