mirror of
https://github.com/bitwarden/server.git
synced 2025-04-05 05:00:19 -05:00
[PM-15015] Add Country Name to auth request from request headers (#5471)
* feat(pm-15015) : * Add `CountryName` column to AuthRequest Table in Database, and refreshing AuthRequestView * Modify database stored procedures and Entity Framework migrations for AuthRequest Repositories * Add property to `ICurrentContext` and response models.
This commit is contained in:
parent
031e188e82
commit
913da4a629
@ -23,6 +23,7 @@ public class PendingOrganizationAuthRequestResponseModel : ResponseModel
|
|||||||
RequestDeviceType = authRequest.RequestDeviceType.GetType().GetMember(authRequest.RequestDeviceType.ToString())
|
RequestDeviceType = authRequest.RequestDeviceType.GetType().GetMember(authRequest.RequestDeviceType.ToString())
|
||||||
.FirstOrDefault()?.GetCustomAttribute<DisplayAttribute>()?.GetName();
|
.FirstOrDefault()?.GetCustomAttribute<DisplayAttribute>()?.GetName();
|
||||||
RequestIpAddress = authRequest.RequestIpAddress;
|
RequestIpAddress = authRequest.RequestIpAddress;
|
||||||
|
RequestCountryName = authRequest.RequestCountryName;
|
||||||
CreationDate = authRequest.CreationDate;
|
CreationDate = authRequest.CreationDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,5 +35,6 @@ public class PendingOrganizationAuthRequestResponseModel : ResponseModel
|
|||||||
public string RequestDeviceIdentifier { get; set; }
|
public string RequestDeviceIdentifier { get; set; }
|
||||||
public string RequestDeviceType { get; set; }
|
public string RequestDeviceType { get; set; }
|
||||||
public string RequestIpAddress { get; set; }
|
public string RequestIpAddress { get; set; }
|
||||||
|
public string RequestCountryName { get; set; }
|
||||||
public DateTime CreationDate { get; set; }
|
public DateTime CreationDate { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ public class AuthRequestResponseModel : ResponseModel
|
|||||||
RequestDeviceType = authRequest.RequestDeviceType.GetType().GetMember(authRequest.RequestDeviceType.ToString())
|
RequestDeviceType = authRequest.RequestDeviceType.GetType().GetMember(authRequest.RequestDeviceType.ToString())
|
||||||
.FirstOrDefault()?.GetCustomAttribute<DisplayAttribute>()?.GetName();
|
.FirstOrDefault()?.GetCustomAttribute<DisplayAttribute>()?.GetName();
|
||||||
RequestIpAddress = authRequest.RequestIpAddress;
|
RequestIpAddress = authRequest.RequestIpAddress;
|
||||||
|
RequestCountryName = authRequest.RequestCountryName;
|
||||||
Key = authRequest.Key;
|
Key = authRequest.Key;
|
||||||
MasterPasswordHash = authRequest.MasterPasswordHash;
|
MasterPasswordHash = authRequest.MasterPasswordHash;
|
||||||
CreationDate = authRequest.CreationDate;
|
CreationDate = authRequest.CreationDate;
|
||||||
@ -37,6 +38,7 @@ public class AuthRequestResponseModel : ResponseModel
|
|||||||
public DeviceType RequestDeviceTypeValue { get; set; }
|
public DeviceType RequestDeviceTypeValue { get; set; }
|
||||||
public string RequestDeviceType { get; set; }
|
public string RequestDeviceType { get; set; }
|
||||||
public string RequestIpAddress { get; set; }
|
public string RequestIpAddress { get; set; }
|
||||||
|
public string RequestCountryName { get; set; }
|
||||||
public string Key { get; set; }
|
public string Key { get; set; }
|
||||||
public string MasterPasswordHash { get; set; }
|
public string MasterPasswordHash { get; set; }
|
||||||
public DateTime CreationDate { get; set; }
|
public DateTime CreationDate { get; set; }
|
||||||
|
@ -16,6 +16,12 @@ public class AuthRequest : ITableObject<Guid>
|
|||||||
public DeviceType RequestDeviceType { get; set; }
|
public DeviceType RequestDeviceType { get; set; }
|
||||||
[MaxLength(50)]
|
[MaxLength(50)]
|
||||||
public string RequestIpAddress { get; set; }
|
public string RequestIpAddress { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// This country name is populated through a header value fetched from the ISO-3166 country code.
|
||||||
|
/// It will always be the English short form of the country name. The length should never be over 200 characters.
|
||||||
|
/// </summary>
|
||||||
|
[MaxLength(200)]
|
||||||
|
public string RequestCountryName { get; set; }
|
||||||
public Guid? ResponseDeviceId { get; set; }
|
public Guid? ResponseDeviceId { get; set; }
|
||||||
[MaxLength(25)]
|
[MaxLength(25)]
|
||||||
public string AccessCode { get; set; }
|
public string AccessCode { get; set; }
|
||||||
|
@ -164,6 +164,7 @@ public class AuthRequestService : IAuthRequestService
|
|||||||
RequestDeviceIdentifier = model.DeviceIdentifier,
|
RequestDeviceIdentifier = model.DeviceIdentifier,
|
||||||
RequestDeviceType = _currentContext.DeviceType.Value,
|
RequestDeviceType = _currentContext.DeviceType.Value,
|
||||||
RequestIpAddress = _currentContext.IpAddress,
|
RequestIpAddress = _currentContext.IpAddress,
|
||||||
|
RequestCountryName = _currentContext.CountryName,
|
||||||
AccessCode = model.AccessCode,
|
AccessCode = model.AccessCode,
|
||||||
PublicKey = model.PublicKey,
|
PublicKey = model.PublicKey,
|
||||||
UserId = user.Id,
|
UserId = user.Id,
|
||||||
@ -176,12 +177,7 @@ public class AuthRequestService : IAuthRequestService
|
|||||||
|
|
||||||
public async Task<AuthRequest> UpdateAuthRequestAsync(Guid authRequestId, Guid currentUserId, AuthRequestUpdateRequestModel model)
|
public async Task<AuthRequest> UpdateAuthRequestAsync(Guid authRequestId, Guid currentUserId, AuthRequestUpdateRequestModel model)
|
||||||
{
|
{
|
||||||
var authRequest = await _authRequestRepository.GetByIdAsync(authRequestId);
|
var authRequest = await _authRequestRepository.GetByIdAsync(authRequestId) ?? throw new NotFoundException();
|
||||||
|
|
||||||
if (authRequest == null)
|
|
||||||
{
|
|
||||||
throw new NotFoundException();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Once Approval/Disapproval has been set, this AuthRequest should not be updated again.
|
// Once Approval/Disapproval has been set, this AuthRequest should not be updated again.
|
||||||
if (authRequest.Approved is not null)
|
if (authRequest.Approved is not null)
|
||||||
|
@ -30,6 +30,7 @@ public class CurrentContext : ICurrentContext
|
|||||||
public virtual string DeviceIdentifier { get; set; }
|
public virtual string DeviceIdentifier { get; set; }
|
||||||
public virtual DeviceType? DeviceType { get; set; }
|
public virtual DeviceType? DeviceType { get; set; }
|
||||||
public virtual string IpAddress { get; set; }
|
public virtual string IpAddress { get; set; }
|
||||||
|
public virtual string CountryName { get; set; }
|
||||||
public virtual List<CurrentContextOrganization> Organizations { get; set; }
|
public virtual List<CurrentContextOrganization> Organizations { get; set; }
|
||||||
public virtual List<CurrentContextProvider> Providers { get; set; }
|
public virtual List<CurrentContextProvider> Providers { get; set; }
|
||||||
public virtual Guid? InstallationId { get; set; }
|
public virtual Guid? InstallationId { get; set; }
|
||||||
@ -104,6 +105,12 @@ public class CurrentContext : ICurrentContext
|
|||||||
{
|
{
|
||||||
ClientVersionIsPrerelease = clientVersionIsPrerelease == "1";
|
ClientVersionIsPrerelease = clientVersionIsPrerelease == "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (httpContext.Request.Headers.TryGetValue("country-name", out var countryName))
|
||||||
|
{
|
||||||
|
CountryName = countryName;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async virtual Task BuildAsync(ClaimsPrincipal user, GlobalSettings globalSettings)
|
public async virtual Task BuildAsync(ClaimsPrincipal user, GlobalSettings globalSettings)
|
||||||
|
@ -20,6 +20,7 @@ public interface ICurrentContext
|
|||||||
string DeviceIdentifier { get; set; }
|
string DeviceIdentifier { get; set; }
|
||||||
DeviceType? DeviceType { get; set; }
|
DeviceType? DeviceType { get; set; }
|
||||||
string IpAddress { get; set; }
|
string IpAddress { get; set; }
|
||||||
|
string CountryName { get; set; }
|
||||||
List<CurrentContextOrganization> Organizations { get; set; }
|
List<CurrentContextOrganization> Organizations { get; set; }
|
||||||
Guid? InstallationId { get; set; }
|
Guid? InstallationId { get; set; }
|
||||||
Guid? OrganizationId { get; set; }
|
Guid? OrganizationId { get; set; }
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
@RequestDeviceIdentifier NVARCHAR(50),
|
@RequestDeviceIdentifier NVARCHAR(50),
|
||||||
@RequestDeviceType TINYINT,
|
@RequestDeviceType TINYINT,
|
||||||
@RequestIpAddress VARCHAR(50),
|
@RequestIpAddress VARCHAR(50),
|
||||||
|
@RequestCountryName NVARCHAR(200),
|
||||||
@ResponseDeviceId UNIQUEIDENTIFIER,
|
@ResponseDeviceId UNIQUEIDENTIFIER,
|
||||||
@AccessCode VARCHAR(25),
|
@AccessCode VARCHAR(25),
|
||||||
@PublicKey VARCHAR(MAX),
|
@PublicKey VARCHAR(MAX),
|
||||||
@ -20,7 +21,7 @@ BEGIN
|
|||||||
SET NOCOUNT ON
|
SET NOCOUNT ON
|
||||||
|
|
||||||
INSERT INTO [dbo].[AuthRequest]
|
INSERT INTO [dbo].[AuthRequest]
|
||||||
(
|
(
|
||||||
[Id],
|
[Id],
|
||||||
[UserId],
|
[UserId],
|
||||||
[OrganizationId],
|
[OrganizationId],
|
||||||
@ -28,6 +29,7 @@ BEGIN
|
|||||||
[RequestDeviceIdentifier],
|
[RequestDeviceIdentifier],
|
||||||
[RequestDeviceType],
|
[RequestDeviceType],
|
||||||
[RequestIpAddress],
|
[RequestIpAddress],
|
||||||
|
[RequestCountryName],
|
||||||
[ResponseDeviceId],
|
[ResponseDeviceId],
|
||||||
[AccessCode],
|
[AccessCode],
|
||||||
[PublicKey],
|
[PublicKey],
|
||||||
@ -37,24 +39,25 @@ BEGIN
|
|||||||
[CreationDate],
|
[CreationDate],
|
||||||
[ResponseDate],
|
[ResponseDate],
|
||||||
[AuthenticationDate]
|
[AuthenticationDate]
|
||||||
)
|
)
|
||||||
VALUES
|
VALUES
|
||||||
(
|
(
|
||||||
@Id,
|
@Id,
|
||||||
@UserId,
|
@UserId,
|
||||||
@OrganizationId,
|
@OrganizationId,
|
||||||
@Type,
|
@Type,
|
||||||
@RequestDeviceIdentifier,
|
@RequestDeviceIdentifier,
|
||||||
@RequestDeviceType,
|
@RequestDeviceType,
|
||||||
@RequestIpAddress,
|
@RequestIpAddress,
|
||||||
@ResponseDeviceId,
|
@RequestCountryName,
|
||||||
@AccessCode,
|
@ResponseDeviceId,
|
||||||
@PublicKey,
|
@AccessCode,
|
||||||
@Key,
|
@PublicKey,
|
||||||
@MasterPasswordHash,
|
@Key,
|
||||||
@Approved,
|
@MasterPasswordHash,
|
||||||
@CreationDate,
|
@Approved,
|
||||||
@ResponseDate,
|
@CreationDate,
|
||||||
@AuthenticationDate
|
@ResponseDate,
|
||||||
|
@AuthenticationDate
|
||||||
)
|
)
|
||||||
END
|
END
|
@ -6,6 +6,7 @@
|
|||||||
@RequestDeviceIdentifier NVARCHAR(50),
|
@RequestDeviceIdentifier NVARCHAR(50),
|
||||||
@RequestDeviceType SMALLINT,
|
@RequestDeviceType SMALLINT,
|
||||||
@RequestIpAddress VARCHAR(50),
|
@RequestIpAddress VARCHAR(50),
|
||||||
|
@RequestCountryName NVARCHAR(200),
|
||||||
@ResponseDeviceId UNIQUEIDENTIFIER,
|
@ResponseDeviceId UNIQUEIDENTIFIER,
|
||||||
@AccessCode VARCHAR(25),
|
@AccessCode VARCHAR(25),
|
||||||
@PublicKey VARCHAR(MAX),
|
@PublicKey VARCHAR(MAX),
|
||||||
@ -20,23 +21,24 @@ BEGIN
|
|||||||
SET NOCOUNT ON
|
SET NOCOUNT ON
|
||||||
|
|
||||||
UPDATE
|
UPDATE
|
||||||
[dbo].[AuthRequest]
|
[dbo].[AuthRequest]
|
||||||
SET
|
SET
|
||||||
[UserId] = @UserId,
|
[UserId] = @UserId,
|
||||||
[Type] = @Type,
|
[Type] = @Type,
|
||||||
[OrganizationId] = @OrganizationId,
|
[OrganizationId] = @OrganizationId,
|
||||||
[RequestDeviceIdentifier] = @RequestDeviceIdentifier,
|
[RequestDeviceIdentifier] = @RequestDeviceIdentifier,
|
||||||
[RequestDeviceType] = @RequestDeviceType,
|
[RequestDeviceType] = @RequestDeviceType,
|
||||||
[RequestIpAddress] = @RequestIpAddress,
|
[RequestIpAddress] = @RequestIpAddress,
|
||||||
[ResponseDeviceId] = @ResponseDeviceId,
|
[RequestCountryName] = @RequestCountryName,
|
||||||
[AccessCode] = @AccessCode,
|
[ResponseDeviceId] = @ResponseDeviceId,
|
||||||
[PublicKey] = @PublicKey,
|
[AccessCode] = @AccessCode,
|
||||||
[Key] = @Key,
|
[PublicKey] = @PublicKey,
|
||||||
[MasterPasswordHash] = @MasterPasswordHash,
|
[Key] = @Key,
|
||||||
[Approved] = @Approved,
|
[MasterPasswordHash] = @MasterPasswordHash,
|
||||||
[CreationDate] = @CreationDate,
|
[Approved] = @Approved,
|
||||||
[ResponseDate] = @ResponseDate,
|
[CreationDate] = @CreationDate,
|
||||||
[AuthenticationDate] = @AuthenticationDate
|
[ResponseDate] = @ResponseDate,
|
||||||
WHERE
|
[AuthenticationDate] = @AuthenticationDate
|
||||||
[Id] = @Id
|
WHERE
|
||||||
|
[Id] = @Id
|
||||||
END
|
END
|
||||||
|
@ -10,6 +10,7 @@ BEGIN
|
|||||||
[RequestDeviceIdentifier] = ARI.[RequestDeviceIdentifier],
|
[RequestDeviceIdentifier] = ARI.[RequestDeviceIdentifier],
|
||||||
[RequestDeviceType] = ARI.[RequestDeviceType],
|
[RequestDeviceType] = ARI.[RequestDeviceType],
|
||||||
[RequestIpAddress] = ARI.[RequestIpAddress],
|
[RequestIpAddress] = ARI.[RequestIpAddress],
|
||||||
|
[RequestCountryName] = ARI.[RequestCountryName],
|
||||||
[ResponseDeviceId] = ARI.[ResponseDeviceId],
|
[ResponseDeviceId] = ARI.[ResponseDeviceId],
|
||||||
[AccessCode] = ARI.[AccessCode],
|
[AccessCode] = ARI.[AccessCode],
|
||||||
[PublicKey] = ARI.[PublicKey],
|
[PublicKey] = ARI.[PublicKey],
|
||||||
@ -22,7 +23,7 @@ BEGIN
|
|||||||
[OrganizationId] = ARI.[OrganizationId]
|
[OrganizationId] = ARI.[OrganizationId]
|
||||||
FROM
|
FROM
|
||||||
[dbo].[AuthRequest] AR
|
[dbo].[AuthRequest] AR
|
||||||
INNER JOIN
|
INNER JOIN
|
||||||
OPENJSON(@jsonData)
|
OPENJSON(@jsonData)
|
||||||
WITH (
|
WITH (
|
||||||
Id UNIQUEIDENTIFIER '$.Id',
|
Id UNIQUEIDENTIFIER '$.Id',
|
||||||
@ -31,6 +32,7 @@ BEGIN
|
|||||||
RequestDeviceIdentifier NVARCHAR(50) '$.RequestDeviceIdentifier',
|
RequestDeviceIdentifier NVARCHAR(50) '$.RequestDeviceIdentifier',
|
||||||
RequestDeviceType SMALLINT '$.RequestDeviceType',
|
RequestDeviceType SMALLINT '$.RequestDeviceType',
|
||||||
RequestIpAddress VARCHAR(50) '$.RequestIpAddress',
|
RequestIpAddress VARCHAR(50) '$.RequestIpAddress',
|
||||||
|
RequestCountryName NVARCHAR(200) '$.RequestCountryName',
|
||||||
ResponseDeviceId UNIQUEIDENTIFIER '$.ResponseDeviceId',
|
ResponseDeviceId UNIQUEIDENTIFIER '$.ResponseDeviceId',
|
||||||
AccessCode VARCHAR(25) '$.AccessCode',
|
AccessCode VARCHAR(25) '$.AccessCode',
|
||||||
PublicKey VARCHAR(MAX) '$.PublicKey',
|
PublicKey VARCHAR(MAX) '$.PublicKey',
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
[ResponseDate] DATETIME2 (7) NULL,
|
[ResponseDate] DATETIME2 (7) NULL,
|
||||||
[AuthenticationDate] DATETIME2 (7) NULL,
|
[AuthenticationDate] DATETIME2 (7) NULL,
|
||||||
[OrganizationId] UNIQUEIDENTIFIER NULL,
|
[OrganizationId] UNIQUEIDENTIFIER NULL,
|
||||||
|
[RequestCountryName] NVARCHAR(200) NULL,
|
||||||
CONSTRAINT [PK_AuthRequest] PRIMARY KEY CLUSTERED ([Id] ASC),
|
CONSTRAINT [PK_AuthRequest] PRIMARY KEY CLUSTERED ([Id] ASC),
|
||||||
CONSTRAINT [FK_AuthRequest_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id]),
|
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])
|
CONSTRAINT [FK_AuthRequest_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
GO
|
GO
|
||||||
|
168
util/Migrator/DbScripts/2025-02-27_00_AlterAuthRequest.sql
Normal file
168
util/Migrator/DbScripts/2025-02-27_00_AlterAuthRequest.sql
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
ALTER TABLE
|
||||||
|
[dbo].[AuthRequest]
|
||||||
|
ADD
|
||||||
|
[RequestCountryName] NVARCHAR(200) NULL;
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXECUTE sp_refreshview 'dbo.AuthRequestView'
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE OR ALTER PROCEDURE [dbo].[AuthRequest_Create]
|
||||||
|
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||||
|
@UserId UNIQUEIDENTIFIER,
|
||||||
|
@OrganizationId UNIQUEIDENTIFIER = NULL,
|
||||||
|
@Type TINYINT,
|
||||||
|
@RequestDeviceIdentifier NVARCHAR(50),
|
||||||
|
@RequestDeviceType TINYINT,
|
||||||
|
@RequestIpAddress VARCHAR(50),
|
||||||
|
@RequestCountryName NVARCHAR(200),
|
||||||
|
@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],
|
||||||
|
[OrganizationId],
|
||||||
|
[Type],
|
||||||
|
[RequestDeviceIdentifier],
|
||||||
|
[RequestDeviceType],
|
||||||
|
[RequestIpAddress],
|
||||||
|
[RequestCountryName],
|
||||||
|
[ResponseDeviceId],
|
||||||
|
[AccessCode],
|
||||||
|
[PublicKey],
|
||||||
|
[Key],
|
||||||
|
[MasterPasswordHash],
|
||||||
|
[Approved],
|
||||||
|
[CreationDate],
|
||||||
|
[ResponseDate],
|
||||||
|
[AuthenticationDate]
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
@Id,
|
||||||
|
@UserId,
|
||||||
|
@OrganizationId,
|
||||||
|
@Type,
|
||||||
|
@RequestDeviceIdentifier,
|
||||||
|
@RequestDeviceType,
|
||||||
|
@RequestIpAddress,
|
||||||
|
@RequestCountryName,
|
||||||
|
@ResponseDeviceId,
|
||||||
|
@AccessCode,
|
||||||
|
@PublicKey,
|
||||||
|
@Key,
|
||||||
|
@MasterPasswordHash,
|
||||||
|
@Approved,
|
||||||
|
@CreationDate,
|
||||||
|
@ResponseDate,
|
||||||
|
@AuthenticationDate
|
||||||
|
)
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE OR ALTER PROCEDURE [dbo].[AuthRequest_Update]
|
||||||
|
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||||
|
@UserId UNIQUEIDENTIFIER,
|
||||||
|
@OrganizationId UNIQUEIDENTIFIER = NULL,
|
||||||
|
@Type SMALLINT,
|
||||||
|
@RequestDeviceIdentifier NVARCHAR(50),
|
||||||
|
@RequestDeviceType SMALLINT,
|
||||||
|
@RequestIpAddress VARCHAR(50),
|
||||||
|
@RequestCountryName NVARCHAR(200),
|
||||||
|
@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,
|
||||||
|
[OrganizationId] = @OrganizationId,
|
||||||
|
[RequestDeviceIdentifier] = @RequestDeviceIdentifier,
|
||||||
|
[RequestDeviceType] = @RequestDeviceType,
|
||||||
|
[RequestIpAddress] = @RequestIpAddress,
|
||||||
|
[RequestCountryName] = @RequestCountryName,
|
||||||
|
[ResponseDeviceId] = @ResponseDeviceId,
|
||||||
|
[AccessCode] = @AccessCode,
|
||||||
|
[PublicKey] = @PublicKey,
|
||||||
|
[Key] = @Key,
|
||||||
|
[MasterPasswordHash] = @MasterPasswordHash,
|
||||||
|
[Approved] = @Approved,
|
||||||
|
[CreationDate] = @CreationDate,
|
||||||
|
[ResponseDate] = @ResponseDate,
|
||||||
|
[AuthenticationDate] = @AuthenticationDate
|
||||||
|
WHERE
|
||||||
|
[Id] = @Id
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE OR ALTER PROCEDURE AuthRequest_UpdateMany
|
||||||
|
@jsonData NVARCHAR(MAX)
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
UPDATE AR
|
||||||
|
SET
|
||||||
|
[Id] = ARI.[Id],
|
||||||
|
[UserId] = ARI.[UserId],
|
||||||
|
[Type] = ARI.[Type],
|
||||||
|
[RequestDeviceIdentifier] = ARI.[RequestDeviceIdentifier],
|
||||||
|
[RequestDeviceType] = ARI.[RequestDeviceType],
|
||||||
|
[RequestIpAddress] = ARI.[RequestIpAddress],
|
||||||
|
[RequestCountryName] = ARI.[RequestCountryName],
|
||||||
|
[ResponseDeviceId] = ARI.[ResponseDeviceId],
|
||||||
|
[AccessCode] = ARI.[AccessCode],
|
||||||
|
[PublicKey] = ARI.[PublicKey],
|
||||||
|
[Key] = ARI.[Key],
|
||||||
|
[MasterPasswordHash] = ARI.[MasterPasswordHash],
|
||||||
|
[Approved] = ARI.[Approved],
|
||||||
|
[CreationDate] = ARI.[CreationDate],
|
||||||
|
[ResponseDate] = ARI.[ResponseDate],
|
||||||
|
[AuthenticationDate] = ARI.[AuthenticationDate],
|
||||||
|
[OrganizationId] = ARI.[OrganizationId]
|
||||||
|
FROM
|
||||||
|
[dbo].[AuthRequest] AR
|
||||||
|
INNER JOIN
|
||||||
|
OPENJSON(@jsonData)
|
||||||
|
WITH (
|
||||||
|
Id UNIQUEIDENTIFIER '$.Id',
|
||||||
|
UserId UNIQUEIDENTIFIER '$.UserId',
|
||||||
|
Type SMALLINT '$.Type',
|
||||||
|
RequestDeviceIdentifier NVARCHAR(50) '$.RequestDeviceIdentifier',
|
||||||
|
RequestDeviceType SMALLINT '$.RequestDeviceType',
|
||||||
|
RequestIpAddress VARCHAR(50) '$.RequestIpAddress',
|
||||||
|
RequestCountryName NVARCHAR(200) '$.RequestCountryName',
|
||||||
|
ResponseDeviceId UNIQUEIDENTIFIER '$.ResponseDeviceId',
|
||||||
|
AccessCode VARCHAR(25) '$.AccessCode',
|
||||||
|
PublicKey VARCHAR(MAX) '$.PublicKey',
|
||||||
|
[Key] VARCHAR(MAX) '$.Key',
|
||||||
|
MasterPasswordHash VARCHAR(MAX) '$.MasterPasswordHash',
|
||||||
|
Approved BIT '$.Approved',
|
||||||
|
CreationDate DATETIME2 '$.CreationDate',
|
||||||
|
ResponseDate DATETIME2 '$.ResponseDate',
|
||||||
|
AuthenticationDate DATETIME2 '$.AuthenticationDate',
|
||||||
|
OrganizationId UNIQUEIDENTIFIER '$.OrganizationId'
|
||||||
|
) ARI ON AR.Id = ARI.Id;
|
||||||
|
END
|
||||||
|
GO
|
3014
util/MySqlMigrations/Migrations/20250304221039_AlterAuthRequest.Designer.cs
generated
Normal file
3014
util/MySqlMigrations/Migrations/20250304221039_AlterAuthRequest.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,29 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Bit.MySqlMigrations.Migrations;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AlterAuthRequest : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "RequestCountryName",
|
||||||
|
table: "AuthRequest",
|
||||||
|
type: "varchar(200)",
|
||||||
|
maxLength: 200,
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "RequestCountryName",
|
||||||
|
table: "AuthRequest");
|
||||||
|
}
|
||||||
|
}
|
@ -407,6 +407,10 @@ namespace Bit.MySqlMigrations.Migrations
|
|||||||
b.Property<DateTime?>("AuthenticationDate")
|
b.Property<DateTime?>("AuthenticationDate")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
|
b.Property<string>("RequestCountryName")
|
||||||
|
.HasMaxLength(200)
|
||||||
|
.HasColumnType("varchar(200)");
|
||||||
|
|
||||||
b.Property<DateTime>("CreationDate")
|
b.Property<DateTime>("CreationDate")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
|
3020
util/PostgresMigrations/Migrations/20250304204625_AlterAuthRequestTable.Designer.cs
generated
Normal file
3020
util/PostgresMigrations/Migrations/20250304204625_AlterAuthRequestTable.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,28 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Bit.PostgresMigrations.Migrations;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AlterAuthRequestTable : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "RequestCountryName",
|
||||||
|
table: "AuthRequest",
|
||||||
|
type: "character varying(200)",
|
||||||
|
maxLength: 200,
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "RequestCountryName",
|
||||||
|
table: "AuthRequest");
|
||||||
|
}
|
||||||
|
}
|
@ -410,6 +410,10 @@ namespace Bit.PostgresMigrations.Migrations
|
|||||||
b.Property<DateTime?>("AuthenticationDate")
|
b.Property<DateTime?>("AuthenticationDate")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("RequestCountryName")
|
||||||
|
.HasMaxLength(200)
|
||||||
|
.HasColumnType("character varying(200)");
|
||||||
|
|
||||||
b.Property<DateTime>("CreationDate")
|
b.Property<DateTime>("CreationDate")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
3003
util/SqliteMigrations/Migrations/20250304204635_AlterAuthRequestTable.Designer.cs
generated
Normal file
3003
util/SqliteMigrations/Migrations/20250304204635_AlterAuthRequestTable.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,28 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Bit.SqliteMigrations.Migrations;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AlterAuthRequestTable : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "RequestCountryName",
|
||||||
|
table: "AuthRequest",
|
||||||
|
type: "TEXT",
|
||||||
|
maxLength: 200,
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "RequestCountryName",
|
||||||
|
table: "AuthRequest");
|
||||||
|
}
|
||||||
|
}
|
@ -402,6 +402,10 @@ namespace Bit.SqliteMigrations.Migrations
|
|||||||
b.Property<DateTime?>("AuthenticationDate")
|
b.Property<DateTime?>("AuthenticationDate")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("RequestCountryName")
|
||||||
|
.HasMaxLength(200)
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<DateTime>("CreationDate")
|
b.Property<DateTime>("CreationDate")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user