mirror of
https://github.com/bitwarden/server.git
synced 2025-07-09 03:43:51 -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:
@ -6,6 +6,7 @@
|
||||
@RequestDeviceIdentifier NVARCHAR(50),
|
||||
@RequestDeviceType TINYINT,
|
||||
@RequestIpAddress VARCHAR(50),
|
||||
@RequestCountryName NVARCHAR(200),
|
||||
@ResponseDeviceId UNIQUEIDENTIFIER,
|
||||
@AccessCode VARCHAR(25),
|
||||
@PublicKey VARCHAR(MAX),
|
||||
@ -20,7 +21,7 @@ BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
INSERT INTO [dbo].[AuthRequest]
|
||||
(
|
||||
(
|
||||
[Id],
|
||||
[UserId],
|
||||
[OrganizationId],
|
||||
@ -28,6 +29,7 @@ BEGIN
|
||||
[RequestDeviceIdentifier],
|
||||
[RequestDeviceType],
|
||||
[RequestIpAddress],
|
||||
[RequestCountryName],
|
||||
[ResponseDeviceId],
|
||||
[AccessCode],
|
||||
[PublicKey],
|
||||
@ -37,24 +39,25 @@ BEGIN
|
||||
[CreationDate],
|
||||
[ResponseDate],
|
||||
[AuthenticationDate]
|
||||
)
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
@Id,
|
||||
@UserId,
|
||||
@OrganizationId,
|
||||
@Type,
|
||||
@RequestDeviceIdentifier,
|
||||
@RequestDeviceType,
|
||||
@RequestIpAddress,
|
||||
@ResponseDeviceId,
|
||||
@AccessCode,
|
||||
@PublicKey,
|
||||
@Key,
|
||||
@MasterPasswordHash,
|
||||
@Approved,
|
||||
@CreationDate,
|
||||
@ResponseDate,
|
||||
@AuthenticationDate
|
||||
(
|
||||
@Id,
|
||||
@UserId,
|
||||
@OrganizationId,
|
||||
@Type,
|
||||
@RequestDeviceIdentifier,
|
||||
@RequestDeviceType,
|
||||
@RequestIpAddress,
|
||||
@RequestCountryName,
|
||||
@ResponseDeviceId,
|
||||
@AccessCode,
|
||||
@PublicKey,
|
||||
@Key,
|
||||
@MasterPasswordHash,
|
||||
@Approved,
|
||||
@CreationDate,
|
||||
@ResponseDate,
|
||||
@AuthenticationDate
|
||||
)
|
||||
END
|
||||
END
|
||||
|
@ -2,10 +2,11 @@
|
||||
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||
@UserId UNIQUEIDENTIFIER,
|
||||
@OrganizationId UNIQUEIDENTIFIER = NULL,
|
||||
@Type SMALLINT,
|
||||
@Type SMALLINT,
|
||||
@RequestDeviceIdentifier NVARCHAR(50),
|
||||
@RequestDeviceType SMALLINT,
|
||||
@RequestIpAddress VARCHAR(50),
|
||||
@RequestCountryName NVARCHAR(200),
|
||||
@ResponseDeviceId UNIQUEIDENTIFIER,
|
||||
@AccessCode VARCHAR(25),
|
||||
@PublicKey VARCHAR(MAX),
|
||||
@ -14,29 +15,30 @@
|
||||
@Approved BIT,
|
||||
@CreationDate DATETIME2 (7),
|
||||
@ResponseDate DATETIME2 (7),
|
||||
@AuthenticationDate 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,
|
||||
[ResponseDeviceId] = @ResponseDeviceId,
|
||||
[AccessCode] = @AccessCode,
|
||||
[PublicKey] = @PublicKey,
|
||||
[Key] = @Key,
|
||||
[MasterPasswordHash] = @MasterPasswordHash,
|
||||
[Approved] = @Approved,
|
||||
[CreationDate] = @CreationDate,
|
||||
[ResponseDate] = @ResponseDate,
|
||||
[AuthenticationDate] = @AuthenticationDate
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
[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
|
||||
|
@ -10,6 +10,7 @@ BEGIN
|
||||
[RequestDeviceIdentifier] = ARI.[RequestDeviceIdentifier],
|
||||
[RequestDeviceType] = ARI.[RequestDeviceType],
|
||||
[RequestIpAddress] = ARI.[RequestIpAddress],
|
||||
[RequestCountryName] = ARI.[RequestCountryName],
|
||||
[ResponseDeviceId] = ARI.[ResponseDeviceId],
|
||||
[AccessCode] = ARI.[AccessCode],
|
||||
[PublicKey] = ARI.[PublicKey],
|
||||
@ -22,7 +23,7 @@ BEGIN
|
||||
[OrganizationId] = ARI.[OrganizationId]
|
||||
FROM
|
||||
[dbo].[AuthRequest] AR
|
||||
INNER JOIN
|
||||
INNER JOIN
|
||||
OPENJSON(@jsonData)
|
||||
WITH (
|
||||
Id UNIQUEIDENTIFIER '$.Id',
|
||||
@ -31,6 +32,7 @@ BEGIN
|
||||
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',
|
||||
|
@ -15,11 +15,11 @@
|
||||
[ResponseDate] DATETIME2 (7) NULL,
|
||||
[AuthenticationDate] DATETIME2 (7) NULL,
|
||||
[OrganizationId] UNIQUEIDENTIFIER NULL,
|
||||
[RequestCountryName] NVARCHAR(200) 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_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id])
|
||||
);
|
||||
|
||||
|
||||
GO
|
||||
|
Reference in New Issue
Block a user