mirror of
https://github.com/bitwarden/server.git
synced 2025-07-11 21:03:47 -05:00
[AC-1192] Create endpoints for new Device Approvals page (#2993)
* [AC-1192] Create new OrganizationAuthRequestsController.cs * [AC-1192] Introduce OrganizationAdminAuthRequest model * [AC-1192] Add GetManyPendingByOrganizationId method to AuthRequest repository * [AC-1192] Add new list pending organization auth requests endpoint * [AC-1192] Add new GetManyAdminApprovalsByManyIdsAsync method to the AuthRequestRepository * [AC-1192] Make the response device identifier optional for admin approval requests * [AC-1192] Add endpoint for bulk denying admin device auth requests * [AC-1192] Add OrganizationUserId to PendingOrganizationAuthRequestResponseModel * [AC-1192] Add UpdateAuthRequest endpoint and logic to OrganizationAuthRequestsController * [AC-1192] Secure new endpoints behind TDE feature flag * [AC-1192] Formatting * [AC-1192] Add sql migration script * [AC-1192] Add optional OrganizationId column to AuthRequest entity - Rename migration script to match existing formatting - Add new column - Add migration scripts - Update new sprocs to filter/join on OrganizationId - Update old sprocs to include OrganizationId * [AC-1192] Format migration scripts * [AC-1192] Fix failing AuthRequest EF unit test * [AC-1192] Make OrganizationId optional in updated AuthRequest sprocs for backwards compatability * [AC-1192] Fix missing comma in migration file * [AC-1192] Rename Key to EncryptedUserKey to be more descriptive * [AC-1192] Move request validation into helper method to reduce repetition * [AC-1192] Return UnauthorizedAccessException instead of NotFound when user is missing permission * [AC-1192] Introduce FeatureUnavailableException * [AC-1192] Introduce RequireFeatureAttribute * [AC-1192] Utilize the new RequireFeatureAttribute in the OrganizationAuthRequestsController * [AC-1192] Attempt to fix out of sync database migration by moving new OrganizationId column * [AC-1192] More attempts to sync database migrations * [AC-1192] Formatting * [AC-1192] Remove unused reference to FeatureService * [AC-1192] Change Id types from String to Guid * [AC-1192] Add EncryptedString attribute * [AC-1192] Remove redundant OrganizationId property * [AC-1192] Switch to projection for OrganizationAdminAuthRequest mapping - Add new OrganizationUser relationship to EF entity - Replace AuthRequest DBContext config with new IEntityTypeConfiguration - Add navigation property to AuthRequest entity configuration for OrganizationUser - Update EF AuthRequestRepository to use new mapping and navigation properties * [AC-1192] Remove OrganizationUser navigation property
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
CREATE PROCEDURE [dbo].[AuthRequest_Create]
|
||||
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||
@UserId UNIQUEIDENTIFIER,
|
||||
@OrganizationId UNIQUEIDENTIFIER = NULL,
|
||||
@Type TINYINT,
|
||||
@RequestDeviceIdentifier NVARCHAR(50),
|
||||
@RequestDeviceType TINYINT,
|
||||
@ -22,6 +23,7 @@ BEGIN
|
||||
(
|
||||
[Id],
|
||||
[UserId],
|
||||
[OrganizationId],
|
||||
[Type],
|
||||
[RequestDeviceIdentifier],
|
||||
[RequestDeviceType],
|
||||
@ -40,6 +42,7 @@ BEGIN
|
||||
(
|
||||
@Id,
|
||||
@UserId,
|
||||
@OrganizationId,
|
||||
@Type,
|
||||
@RequestDeviceIdentifier,
|
||||
@RequestDeviceType,
|
||||
@ -54,4 +57,4 @@ BEGIN
|
||||
@ResponseDate,
|
||||
@AuthenticationDate
|
||||
)
|
||||
END
|
||||
END
|
@ -0,0 +1,20 @@
|
||||
CREATE PROCEDURE [dbo].[AuthRequest_ReadAdminApprovalsByIds]
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@Ids AS [dbo].[GuidIdArray] READONLY
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT
|
||||
ar.*, ou.[Email], ou.[Id] AS [OrganizationUserId]
|
||||
FROM
|
||||
[dbo].[AuthRequestView] ar
|
||||
INNER JOIN
|
||||
[dbo].[OrganizationUser] ou ON ou.[UserId] = ar.[UserId] AND ou.[OrganizationId] = ar.[OrganizationId]
|
||||
WHERE
|
||||
ar.[OrganizationId] = @OrganizationId
|
||||
AND
|
||||
ar.[Type] = 2 -- AdminApproval
|
||||
AND
|
||||
ar.[Id] IN (SELECT [Id] FROM @Ids)
|
||||
END
|
@ -0,0 +1,19 @@
|
||||
CREATE PROCEDURE [dbo].[AuthRequest_ReadPendingByOrganizationId]
|
||||
@OrganizationId UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT
|
||||
ar.*, ou.[Email], ou.[OrganizationId], ou.[Id] AS [OrganizationUserId]
|
||||
FROM
|
||||
[dbo].[AuthRequestView] ar
|
||||
INNER JOIN
|
||||
[dbo].[OrganizationUser] ou ON ou.[UserId] = ar.[UserId] AND ou.[OrganizationId] = ar.[OrganizationId]
|
||||
WHERE
|
||||
ar.[OrganizationId] = @OrganizationId
|
||||
AND
|
||||
ar.[ResponseDate] IS NULL
|
||||
AND
|
||||
ar.[Type] = 2 -- AdminApproval
|
||||
END
|
@ -1,6 +1,7 @@
|
||||
CREATE PROCEDURE [dbo].[AuthRequest_Update]
|
||||
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||
@UserId UNIQUEIDENTIFIER,
|
||||
@OrganizationId UNIQUEIDENTIFIER = NULL,
|
||||
@Type SMALLINT,
|
||||
@RequestDeviceIdentifier NVARCHAR(50),
|
||||
@RequestDeviceType SMALLINT,
|
||||
@ -23,6 +24,7 @@ BEGIN
|
||||
SET
|
||||
[UserId] = @UserId,
|
||||
[Type] = @Type,
|
||||
[OrganizationId] = @OrganizationId,
|
||||
[RequestDeviceIdentifier] = @RequestDeviceIdentifier,
|
||||
[RequestDeviceType] = @RequestDeviceType,
|
||||
[RequestIpAddress] = @RequestIpAddress,
|
||||
|
@ -14,9 +14,11 @@
|
||||
[CreationDate] DATETIME2 (7) NOT NULL,
|
||||
[ResponseDate] DATETIME2 (7) NULL,
|
||||
[AuthenticationDate] DATETIME2 (7) NULL,
|
||||
[OrganizationId] UNIQUEIDENTIFIER NULL,
|
||||
CONSTRAINT [PK_AuthRequest] PRIMARY KEY CLUSTERED ([Id] ASC),
|
||||
CONSTRAINT [FK_AuthRequest_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id]),
|
||||
CONSTRAINT [FK_AuthRequest_ResponseDevice] FOREIGN KEY ([ResponseDeviceId]) REFERENCES [dbo].[Device] ([Id])
|
||||
CONSTRAINT [FK_AuthRequest_ResponseDevice] FOREIGN KEY ([ResponseDeviceId]) REFERENCES [dbo].[Device] ([Id]),
|
||||
CONSTRAINT [FK_AuthRequest_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id])
|
||||
);
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user