mirror of
https://github.com/bitwarden/server.git
synced 2025-02-27 03:41:30 +01:00
Add support for new collection access, hide passwords
This commit is contained in:
parent
0cd90be83a
commit
36f15c67d0
@ -11,13 +11,15 @@ namespace Bit.Core.Models.Api
|
||||
[Required]
|
||||
public string Id { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
public bool HidePasswords { get; set; }
|
||||
|
||||
public SelectionReadOnly ToSelectionReadOnly()
|
||||
{
|
||||
return new SelectionReadOnly
|
||||
{
|
||||
Id = new Guid(Id),
|
||||
ReadOnly = ReadOnly
|
||||
ReadOnly = ReadOnly,
|
||||
HidePasswords = HidePasswords
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -89,11 +89,13 @@ namespace Bit.Core.Models.Api
|
||||
FolderId = cipher.FolderId?.ToString();
|
||||
Favorite = cipher.Favorite;
|
||||
Edit = cipher.Edit;
|
||||
ViewPassword = cipher.ViewPassword;
|
||||
}
|
||||
|
||||
public string FolderId { get; set; }
|
||||
public bool Favorite { get; set; }
|
||||
public bool Edit { get; set; }
|
||||
public bool ViewPassword { get; set; }
|
||||
}
|
||||
|
||||
public class CipherDetailsResponseModel : CipherResponseModel
|
||||
|
@ -34,9 +34,11 @@ namespace Bit.Core.Models.Api
|
||||
: base(collectionDetails, "collectionDetails")
|
||||
{
|
||||
ReadOnly = collectionDetails.ReadOnly;
|
||||
HidePasswords = collectionDetails.HidePasswords;
|
||||
}
|
||||
|
||||
public bool ReadOnly { get; set; }
|
||||
public bool HidePasswords { get; set; }
|
||||
}
|
||||
|
||||
public class CollectionGroupDetailsResponseModel : CollectionResponseModel
|
||||
|
@ -14,9 +14,11 @@ namespace Bit.Core.Models.Api
|
||||
|
||||
Id = selection.Id.ToString();
|
||||
ReadOnly = selection.ReadOnly;
|
||||
HidePasswords = selection.HidePasswords;
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
public bool HidePasswords { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -7,5 +7,6 @@ namespace Core.Models.Data
|
||||
public Guid? FolderId { get; set; }
|
||||
public bool Favorite { get; set; }
|
||||
public bool Edit { get; set; }
|
||||
public bool ViewPassword { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -5,5 +5,6 @@ namespace Bit.Core.Models.Data
|
||||
public class CollectionDetails : Collection
|
||||
{
|
||||
public bool ReadOnly { get; set; }
|
||||
public bool HidePasswords { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -6,5 +6,6 @@ namespace Bit.Core.Models.Data
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
public bool HidePasswords { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -125,6 +125,8 @@ namespace Bit.Core.Utilities
|
||||
table.Columns.Add(idColumn);
|
||||
var readOnlyColumn = new DataColumn("ReadOnly", typeof(bool));
|
||||
table.Columns.Add(readOnlyColumn);
|
||||
var hidePasswordsColumn = new DataColumn("HidePasswords", typeof(bool));
|
||||
table.Columns.Add(hidePasswordsColumn);
|
||||
|
||||
if (values != null)
|
||||
{
|
||||
@ -133,6 +135,7 @@ namespace Bit.Core.Utilities
|
||||
var row = table.NewRow();
|
||||
row[idColumn] = value.Id;
|
||||
row[readOnlyColumn] = value.ReadOnly;
|
||||
row[hidePasswordsColumn] = value.HidePasswords;
|
||||
table.Rows.Add(row);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,13 @@ SELECT
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END [Edit],
|
||||
CASE
|
||||
WHEN
|
||||
CU.[HidePasswords] = 0
|
||||
OR CG.[HidePasswords] = 0
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END [ViewPassword],
|
||||
CASE
|
||||
WHEN O.[UseTotp] = 1
|
||||
THEN 1
|
||||
@ -55,6 +62,7 @@ UNION ALL
|
||||
SELECT
|
||||
*,
|
||||
1 [Edit],
|
||||
1 [ViewPassword],
|
||||
0 [OrganizationUseTotp]
|
||||
FROM
|
||||
[dbo].[CipherDetails](@UserId)
|
||||
|
@ -11,7 +11,14 @@ SELECT
|
||||
OR CG.[ReadOnly] = 0
|
||||
THEN 0
|
||||
ELSE 1
|
||||
END [ReadOnly]
|
||||
END [ReadOnly],
|
||||
CASE
|
||||
WHEN
|
||||
CU.[HidePasswords] = 0
|
||||
OR CG.[HidePasswords] = 0
|
||||
THEN 0
|
||||
ELSE 1
|
||||
END [HidePasswords]
|
||||
FROM
|
||||
[dbo].[CollectionView] C
|
||||
INNER JOIN
|
||||
|
@ -6,7 +6,8 @@ BEGIN
|
||||
|
||||
SELECT
|
||||
[OrganizationUserId] [Id],
|
||||
[ReadOnly]
|
||||
[ReadOnly],
|
||||
[HidePasswords]
|
||||
FROM
|
||||
[dbo].[CollectionUser]
|
||||
WHERE
|
||||
|
@ -35,10 +35,15 @@ BEGIN
|
||||
(
|
||||
@CollectionId,
|
||||
[Source].[Id],
|
||||
[Source].[ReadOnly]
|
||||
[Source].[ReadOnly],
|
||||
[Source].[HidePasswords]
|
||||
)
|
||||
WHEN MATCHED AND [Target].[ReadOnly] != [Source].[ReadOnly] THEN
|
||||
UPDATE SET [Target].[ReadOnly] = [Source].[ReadOnly]
|
||||
WHEN MATCHED AND (
|
||||
[Target].[ReadOnly] != [Source].[ReadOnly]
|
||||
OR [Target].[HidePasswords] != [Source].[HidePasswords]
|
||||
) THEN
|
||||
UPDATE SET [Target].[ReadOnly] = [Source].[ReadOnly],
|
||||
[Target].[HidePasswords] = [Source].[HidePasswords]
|
||||
WHEN NOT MATCHED BY SOURCE
|
||||
AND [Target].[CollectionId] = @CollectionId THEN
|
||||
DELETE
|
||||
|
@ -24,12 +24,14 @@ BEGIN
|
||||
(
|
||||
[CollectionId],
|
||||
[GroupId],
|
||||
[ReadOnly]
|
||||
[ReadOnly],
|
||||
[HidePasswords]
|
||||
)
|
||||
SELECT
|
||||
@Id,
|
||||
[Id],
|
||||
[ReadOnly]
|
||||
[ReadOnly],
|
||||
[HidePasswords]
|
||||
FROM
|
||||
@Groups
|
||||
WHERE
|
||||
|
@ -8,7 +8,8 @@ BEGIN
|
||||
|
||||
SELECT
|
||||
[GroupId] [Id],
|
||||
[ReadOnly]
|
||||
[ReadOnly],
|
||||
[HidePasswords]
|
||||
FROM
|
||||
[dbo].[CollectionGroup]
|
||||
WHERE
|
||||
|
@ -9,7 +9,8 @@ BEGIN
|
||||
|
||||
SELECT
|
||||
[GroupId] [Id],
|
||||
[ReadOnly]
|
||||
[ReadOnly],
|
||||
[HidePasswords]
|
||||
FROM
|
||||
[dbo].[CollectionGroup]
|
||||
WHERE
|
||||
|
@ -33,10 +33,15 @@ BEGIN
|
||||
(
|
||||
@Id,
|
||||
[Source].[Id],
|
||||
[Source].[ReadOnly]
|
||||
[Source].[ReadOnly],
|
||||
[Source].[HidePasswords]
|
||||
)
|
||||
WHEN MATCHED AND [Target].[ReadOnly] != [Source].[ReadOnly] THEN
|
||||
UPDATE SET [Target].[ReadOnly] = [Source].[ReadOnly]
|
||||
WHEN MATCHED AND (
|
||||
[Target].[ReadOnly] != [Source].[ReadOnly]
|
||||
OR [Target].[HidePasswords] != [Source].[HidePasswords]
|
||||
) THEN
|
||||
UPDATE SET [Target].[ReadOnly] = [Source].[ReadOnly],
|
||||
[Target].[HidePasswords] = [Source].[HidePasswords]
|
||||
WHEN NOT MATCHED BY SOURCE
|
||||
AND [Target].[CollectionId] = @Id THEN
|
||||
DELETE
|
||||
|
@ -25,12 +25,14 @@ BEGIN
|
||||
(
|
||||
[CollectionId],
|
||||
[GroupId],
|
||||
[ReadOnly]
|
||||
[ReadOnly],
|
||||
[HidePasswords]
|
||||
)
|
||||
SELECT
|
||||
[Id],
|
||||
@Id,
|
||||
[ReadOnly]
|
||||
[ReadOnly],
|
||||
[HidePasswords]
|
||||
FROM
|
||||
@Collections
|
||||
WHERE
|
||||
|
@ -8,7 +8,8 @@ BEGIN
|
||||
|
||||
SELECT
|
||||
[CollectionId] [Id],
|
||||
[ReadOnly]
|
||||
[ReadOnly],
|
||||
[HidePasswords]
|
||||
FROM
|
||||
[dbo].[CollectionGroup]
|
||||
WHERE
|
||||
|
@ -34,10 +34,15 @@ BEGIN
|
||||
(
|
||||
[Source].[Id],
|
||||
@Id,
|
||||
[Source].[ReadOnly]
|
||||
[Source].[ReadOnly],
|
||||
[Source].[HidePasswords]
|
||||
)
|
||||
WHEN MATCHED AND [Target].[ReadOnly] != [Source].[ReadOnly] THEN
|
||||
UPDATE SET [Target].[ReadOnly] = [Source].[ReadOnly]
|
||||
WHEN MATCHED AND (
|
||||
[Target].[ReadOnly] != [Source].[ReadOnly]
|
||||
OR [Target].[HidePasswords] != [Source].[HidePasswords]
|
||||
) THEN
|
||||
UPDATE SET [Target].[ReadOnly] = [Source].[ReadOnly],
|
||||
[Target].[HidePasswords] = [Source].[HidePasswords]
|
||||
WHEN NOT MATCHED BY SOURCE
|
||||
AND [Target].[GroupId] = @Id THEN
|
||||
DELETE
|
||||
|
@ -8,7 +8,8 @@ BEGIN
|
||||
|
||||
SELECT
|
||||
CU.[CollectionId] Id,
|
||||
CU.[ReadOnly]
|
||||
CU.[ReadOnly],
|
||||
CU.[HidePasswords]
|
||||
FROM
|
||||
[dbo].[OrganizationUser] OU
|
||||
INNER JOIN
|
||||
|
@ -29,12 +29,14 @@ BEGIN
|
||||
(
|
||||
[CollectionId],
|
||||
[OrganizationUserId],
|
||||
[ReadOnly]
|
||||
[ReadOnly],
|
||||
[HidePasswords]
|
||||
)
|
||||
SELECT
|
||||
[Id],
|
||||
@Id,
|
||||
[ReadOnly]
|
||||
[ReadOnly],
|
||||
[HidePasswords]
|
||||
FROM
|
||||
@Collections
|
||||
WHERE
|
||||
|
@ -8,7 +8,8 @@ BEGIN
|
||||
|
||||
SELECT
|
||||
CU.[CollectionId] Id,
|
||||
CU.[ReadOnly]
|
||||
CU.[ReadOnly],
|
||||
CU.[HidePasswords]
|
||||
FROM
|
||||
[dbo].[OrganizationUser] OU
|
||||
INNER JOIN
|
||||
|
@ -38,10 +38,15 @@ BEGIN
|
||||
(
|
||||
[Source].[Id],
|
||||
@Id,
|
||||
[Source].[ReadOnly]
|
||||
[Source].[ReadOnly],
|
||||
[Source].[HidePasswords]
|
||||
)
|
||||
WHEN MATCHED AND [Target].[ReadOnly] != [Source].[ReadOnly] THEN
|
||||
UPDATE SET [Target].[ReadOnly] = [Source].[ReadOnly]
|
||||
WHEN MATCHED AND (
|
||||
[Target].[ReadOnly] != [Source].[ReadOnly]
|
||||
OR [Target].[HidePasswords] != [Source].[HidePasswords]
|
||||
) THEN
|
||||
UPDATE SET [Target].[ReadOnly] = [Source].[ReadOnly],
|
||||
[Target].[HidePasswords] = [Source].[HidePasswords]
|
||||
WHEN NOT MATCHED BY SOURCE
|
||||
AND [Target].[OrganizationUserId] = @Id THEN
|
||||
DELETE
|
||||
|
@ -1,7 +1,8 @@
|
||||
CREATE TABLE [dbo].[CollectionGroup] (
|
||||
[CollectionId] UNIQUEIDENTIFIER NOT NULL,
|
||||
[GroupId] UNIQUEIDENTIFIER NOT NULL,
|
||||
[ReadOnly] BIT NOT NULL,
|
||||
[CollectionId] UNIQUEIDENTIFIER NOT NULL,
|
||||
[GroupId] UNIQUEIDENTIFIER NOT NULL,
|
||||
[ReadOnly] BIT NOT NULL,
|
||||
[HidePasswords] BIT NOT NULL DEFAULT 0,
|
||||
CONSTRAINT [PK_CollectionGroup] PRIMARY KEY CLUSTERED ([CollectionId] ASC, [GroupId] ASC),
|
||||
CONSTRAINT [FK_CollectionGroup_Collection] FOREIGN KEY ([CollectionId]) REFERENCES [dbo].[Collection] ([Id]),
|
||||
CONSTRAINT [FK_CollectionGroup_Group] FOREIGN KEY ([GroupId]) REFERENCES [dbo].[Group] ([Id]) ON DELETE CASCADE
|
||||
|
@ -2,6 +2,7 @@
|
||||
[CollectionId] UNIQUEIDENTIFIER NOT NULL,
|
||||
[OrganizationUserId] UNIQUEIDENTIFIER NOT NULL,
|
||||
[ReadOnly] BIT NOT NULL,
|
||||
[HidePasswords] BIT NOT NULL DEFAULT 0,
|
||||
CONSTRAINT [PK_CollectionUser] PRIMARY KEY CLUSTERED ([CollectionId] ASC, [OrganizationUserId] ASC),
|
||||
CONSTRAINT [FK_CollectionUser_Collection] FOREIGN KEY ([CollectionId]) REFERENCES [dbo].[Collection] ([Id]) ON DELETE CASCADE,
|
||||
CONSTRAINT [FK_CollectionUser_OrganizationUser] FOREIGN KEY ([OrganizationUserId]) REFERENCES [dbo].[OrganizationUser] ([Id])
|
||||
|
@ -1,4 +1,5 @@
|
||||
CREATE TYPE [dbo].[SelectionReadOnlyArray] AS TABLE (
|
||||
[Id] UNIQUEIDENTIFIER NOT NULL,
|
||||
[ReadOnly] BIT NOT NULL);
|
||||
[Id] UNIQUEIDENTIFIER NOT NULL,
|
||||
[ReadOnly] BIT NOT NULL,
|
||||
[HidePasswords] BIT NOT NULL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user