Browse Source
* Added migrations for sqlserver and mysql * Added migrations for postgres * renamed mysql migration script to make naming uniform * introduced approved field to the update auth request controller;This change would keep track of denied passwordless requests * Recreated the authRequestView, introduced the approved field to the create procedure and updated the response model * Formatted code * fixed incorrect syntax in the AuthRequest_Create.sql SPpull/2367/head
15 changed files with 3591 additions and 12 deletions
@ -0,0 +1,145 @@
@@ -0,0 +1,145 @@
|
||||
--Add Column |
||||
IF COL_LENGTH('[dbo].[AuthRequest]', 'Approved') IS NULL |
||||
BEGIN |
||||
ALTER TABLE |
||||
[dbo].[AuthRequest] |
||||
ADD |
||||
[Approved] BIT NULL |
||||
END |
||||
GO |
||||
|
||||
-- Drop and recreate view |
||||
IF EXISTS(SELECT * FROM sys.views WHERE [Name] = 'AuthRequestView') |
||||
BEGIN |
||||
DROP VIEW [dbo].[AuthRequestView] |
||||
END |
||||
GO |
||||
|
||||
CREATE VIEW [dbo].[AuthRequestView] |
||||
AS |
||||
SELECT |
||||
* |
||||
FROM |
||||
[dbo].[AuthRequest] |
||||
GO |
||||
|
||||
--Drop existing SPROC |
||||
IF OBJECT_ID('[dbo].[AuthRequest_Update]') IS NOT NULL |
||||
BEGIN |
||||
DROP PROCEDURE [dbo].[AuthRequest_Update] |
||||
END |
||||
GO |
||||
|
||||
--Create SPROC with new column |
||||
CREATE PROCEDURE [dbo].[AuthRequest_Update] |
||||
@Id UNIQUEIDENTIFIER OUTPUT, |
||||
@UserId UNIQUEIDENTIFIER, |
||||
@Type SMALLINT, |
||||
@RequestDeviceIdentifier NVARCHAR(50), |
||||
@RequestDeviceType SMALLINT, |
||||
@RequestIpAddress VARCHAR(50), |
||||
@RequestFingerprint VARCHAR(MAX), |
||||
@ResponseDeviceId UNIQUEIDENTIFIER, |
||||
@AccessCode VARCHAR(25), |
||||
@PublicKey VARCHAR(MAX), |
||||
@Key VARCHAR(MAX), |
||||
@MasterPasswordHash VARCHAR(MAX), |
||||
@Approved BIT, |
||||
@CreationDate DATETIME2 (7), |
||||
@ResponseDate DATETIME2 (7), |
||||
@AuthenticationDate DATETIME2 (7) |
||||
AS |
||||
BEGIN |
||||
SET NOCOUNT ON |
||||
|
||||
UPDATE |
||||
[dbo].[AuthRequest] |
||||
SET |
||||
[UserId] = @UserId, |
||||
[Type] = @Type, |
||||
[RequestDeviceIdentifier] = @RequestDeviceIdentifier, |
||||
[RequestDeviceType] = @RequestDeviceType, |
||||
[RequestIpAddress] = @RequestIpAddress, |
||||
[RequestFingerprint] = @RequestFingerprint, |
||||
[ResponseDeviceId] = @ResponseDeviceId, |
||||
[AccessCode] = @AccessCode, |
||||
[PublicKey] = @PublicKey, |
||||
[Key] = @Key, |
||||
[MasterPasswordHash] = @MasterPasswordHash, |
||||
[Approved] = @Approved, |
||||
[CreationDate] = @CreationDate, |
||||
[ResponseDate] = @ResponseDate, |
||||
[AuthenticationDate] = @AuthenticationDate |
||||
WHERE |
||||
[Id] = @Id |
||||
END |
||||
GO |
||||
|
||||
--Drop existing SPROC |
||||
IF OBJECT_ID('[dbo].[AuthRequest_Create]') IS NOT NULL |
||||
BEGIN |
||||
DROP PROCEDURE [dbo].[AuthRequest_Create] |
||||
END |
||||
GO |
||||
|
||||
--Create SPROC with new column |
||||
CREATE PROCEDURE [dbo].[AuthRequest_Create] |
||||
@Id UNIQUEIDENTIFIER OUTPUT, |
||||
@UserId UNIQUEIDENTIFIER, |
||||
@Type TINYINT, |
||||
@RequestDeviceIdentifier NVARCHAR(50), |
||||
@RequestDeviceType TINYINT, |
||||
@RequestIpAddress VARCHAR(50), |
||||
@RequestFingerprint VARCHAR(MAX), |
||||
@ResponseDeviceId UNIQUEIDENTIFIER, |
||||
@AccessCode VARCHAR(25), |
||||
@PublicKey VARCHAR(MAX), |
||||
@Key VARCHAR(MAX), |
||||
@MasterPasswordHash VARCHAR(MAX), |
||||
@Approved BIT, |
||||
@CreationDate DATETIME2(7), |
||||
@ResponseDate DATETIME2(7), |
||||
@AuthenticationDate DATETIME2(7) |
||||
AS |
||||
BEGIN |
||||
SET NOCOUNT ON |
||||
|
||||
INSERT INTO [dbo].[AuthRequest] |
||||
( |
||||
[Id], |
||||
[UserId], |
||||
[Type], |
||||
[RequestDeviceIdentifier], |
||||
[RequestDeviceType], |
||||
[RequestIpAddress], |
||||
[RequestFingerprint], |
||||
[ResponseDeviceId], |
||||
[AccessCode], |
||||
[PublicKey], |
||||
[Key], |
||||
[MasterPasswordHash], |
||||
[Approved], |
||||
[CreationDate], |
||||
[ResponseDate], |
||||
[AuthenticationDate] |
||||
) |
||||
VALUES |
||||
( |
||||
@Id, |
||||
@UserId, |
||||
@Type, |
||||
@RequestDeviceIdentifier, |
||||
@RequestDeviceType, |
||||
@RequestIpAddress, |
||||
@RequestFingerprint, |
||||
@ResponseDeviceId, |
||||
@AccessCode, |
||||
@PublicKey, |
||||
@Key, |
||||
@MasterPasswordHash, |
||||
@Approved, |
||||
@CreationDate, |
||||
@ResponseDate, |
||||
@AuthenticationDate |
||||
) |
||||
END |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
||||
#nullable disable |
||||
|
||||
namespace Bit.MySqlMigrations.Migrations; |
||||
|
||||
public partial class PasswordlessAuthRequestAddApprovedColumn : Migration |
||||
{ |
||||
protected override void Up(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.AddColumn<bool>( |
||||
name: "Approved", |
||||
table: "AuthRequest", |
||||
type: "tinyint(1)", |
||||
nullable: true); |
||||
} |
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.DropColumn( |
||||
name: "Approved", |
||||
table: "AuthRequest"); |
||||
} |
||||
} |
||||
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
START TRANSACTION; |
||||
|
||||
ALTER TABLE `AuthRequest` ADD `Approved` tinyint(1) NULL; |
||||
|
||||
INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) |
||||
VALUES ('20221024210500_PasswordlessAuthRequestAddApprovedColumn', '6.0.4'); |
||||
|
||||
COMMIT; |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
||||
#nullable disable |
||||
|
||||
namespace Bit.PostgresMigrations.Migrations; |
||||
|
||||
public partial class PasswordlessAuthRequestAddApprovedColumn : Migration |
||||
{ |
||||
protected override void Up(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.AddColumn<bool>( |
||||
name: "Approved", |
||||
table: "AuthRequest", |
||||
type: "boolean", |
||||
nullable: true); |
||||
} |
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder) |
||||
{ |
||||
migrationBuilder.DropColumn( |
||||
name: "Approved", |
||||
table: "AuthRequest"); |
||||
} |
||||
} |
||||
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
START TRANSACTION; |
||||
|
||||
ALTER TABLE "AuthRequest" ADD "Approved" boolean NULL; |
||||
|
||||
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") |
||||
VALUES ('20221025033204_PasswordlessAuthRequestAddApprovedColumn', '6.0.4'); |
||||
|
||||
COMMIT; |
||||
Loading…
Reference in new issue