mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
[SM-389] Event log for service account (#2674)
This commit is contained in:
100
util/Migrator/DbScripts/2023-02-16_00_SecretsManagerEvent.sql
Normal file
100
util/Migrator/DbScripts/2023-02-16_00_SecretsManagerEvent.sql
Normal file
@ -0,0 +1,100 @@
|
||||
IF COL_LENGTH('[dbo].[Event]', 'SecretId') IS NULL
|
||||
BEGIN
|
||||
ALTER TABLE
|
||||
[dbo].[Event]
|
||||
ADD
|
||||
[SecretId] UNIQUEIDENTIFIER NULL
|
||||
END
|
||||
GO
|
||||
|
||||
IF COL_LENGTH('[dbo].[Event]', 'ServiceAccountId') IS NULL
|
||||
BEGIN
|
||||
ALTER TABLE
|
||||
[dbo].[Event]
|
||||
ADD
|
||||
[ServiceAccountId] UNIQUEIDENTIFIER NULL
|
||||
END
|
||||
GO
|
||||
|
||||
IF OBJECT_ID('[dbo].[EventView]') IS NOT NULL
|
||||
BEGIN
|
||||
EXECUTE sp_refreshsqlmodule N'[dbo].[EventView]';
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE OR ALTER PROCEDURE [dbo].[Event_Create]
|
||||
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||
@Type INT,
|
||||
@UserId UNIQUEIDENTIFIER,
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@InstallationId UNIQUEIDENTIFIER,
|
||||
@ProviderId UNIQUEIDENTIFIER,
|
||||
@CipherId UNIQUEIDENTIFIER,
|
||||
@CollectionId UNIQUEIDENTIFIER,
|
||||
@PolicyId UNIQUEIDENTIFIER,
|
||||
@GroupId UNIQUEIDENTIFIER,
|
||||
@OrganizationUserId UNIQUEIDENTIFIER,
|
||||
@ProviderUserId UNIQUEIDENTIFIER,
|
||||
@ProviderOrganizationId UNIQUEIDENTIFIER = null,
|
||||
@ActingUserId UNIQUEIDENTIFIER,
|
||||
@DeviceType SMALLINT,
|
||||
@IpAddress VARCHAR(50),
|
||||
@Date DATETIME2(7),
|
||||
@SystemUser TINYINT = null,
|
||||
@DomainName VARCHAR(256),
|
||||
@SecretId UNIQUEIDENTIFIER = null,
|
||||
@ServiceAccountId UNIQUEIDENTIFIER = null
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
INSERT INTO [dbo].[Event]
|
||||
(
|
||||
[Id],
|
||||
[Type],
|
||||
[UserId],
|
||||
[OrganizationId],
|
||||
[InstallationId],
|
||||
[ProviderId],
|
||||
[CipherId],
|
||||
[CollectionId],
|
||||
[PolicyId],
|
||||
[GroupId],
|
||||
[OrganizationUserId],
|
||||
[ProviderUserId],
|
||||
[ProviderOrganizationId],
|
||||
[ActingUserId],
|
||||
[DeviceType],
|
||||
[IpAddress],
|
||||
[Date],
|
||||
[SystemUser],
|
||||
[DomainName],
|
||||
[SecretId],
|
||||
[ServiceAccountId]
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
@Id,
|
||||
@Type,
|
||||
@UserId,
|
||||
@OrganizationId,
|
||||
@InstallationId,
|
||||
@ProviderId,
|
||||
@CipherId,
|
||||
@CollectionId,
|
||||
@PolicyId,
|
||||
@GroupId,
|
||||
@OrganizationUserId,
|
||||
@ProviderUserId,
|
||||
@ProviderOrganizationId,
|
||||
@ActingUserId,
|
||||
@DeviceType,
|
||||
@IpAddress,
|
||||
@Date,
|
||||
@SystemUser,
|
||||
@DomainName,
|
||||
@SecretId,
|
||||
@ServiceAccountId
|
||||
)
|
||||
END
|
||||
GO
|
2138
util/MySqlMigrations/Migrations/20230213133250_SecretsManagerEvent.Designer.cs
generated
Normal file
2138
util/MySqlMigrations/Migrations/20230213133250_SecretsManagerEvent.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,36 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bit.MySqlMigrations.Migrations;
|
||||
|
||||
public partial class SecretsManagerEvent : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "SecretId",
|
||||
table: "Event",
|
||||
type: "char(36)",
|
||||
nullable: true,
|
||||
collation: "ascii_general_ci");
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "ServiceAccountId",
|
||||
table: "Event",
|
||||
type: "char(36)",
|
||||
nullable: true,
|
||||
collation: "ascii_general_ci");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SecretId",
|
||||
table: "Event");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ServiceAccountId",
|
||||
table: "Event");
|
||||
}
|
||||
}
|
@ -349,6 +349,12 @@ namespace Bit.MySqlMigrations.Migrations
|
||||
b.Property<Guid?>("ProviderUserId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("SecretId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("ServiceAccountId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<byte?>("SystemUser")
|
||||
.HasColumnType("tinyint unsigned");
|
||||
|
||||
|
2149
util/PostgresMigrations/Migrations/20230213133239_SecretsManagerEvent.Designer.cs
generated
Normal file
2149
util/PostgresMigrations/Migrations/20230213133239_SecretsManagerEvent.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bit.PostgresMigrations.Migrations;
|
||||
|
||||
public partial class SecretsManagerEvent : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "SecretId",
|
||||
table: "Event",
|
||||
type: "uuid",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "ServiceAccountId",
|
||||
table: "Event",
|
||||
type: "uuid",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SecretId",
|
||||
table: "Event");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ServiceAccountId",
|
||||
table: "Event");
|
||||
}
|
||||
}
|
@ -353,6 +353,12 @@ namespace Bit.PostgresMigrations.Migrations
|
||||
b.Property<Guid?>("ProviderUserId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid?>("SecretId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid?>("ServiceAccountId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<byte?>("SystemUser")
|
||||
.HasColumnType("smallint");
|
||||
|
||||
|
2136
util/SqliteMigrations/Migrations/20230213133244_SecretsManagerEvent.Designer.cs
generated
Normal file
2136
util/SqliteMigrations/Migrations/20230213133244_SecretsManagerEvent.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Bit.SqliteMigrations.Migrations;
|
||||
|
||||
public partial class SecretsManagerEvent : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "SecretId",
|
||||
table: "Event",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "ServiceAccountId",
|
||||
table: "Event",
|
||||
type: "TEXT",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "SecretId",
|
||||
table: "Event");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ServiceAccountId",
|
||||
table: "Event");
|
||||
}
|
||||
}
|
@ -344,6 +344,12 @@ namespace Bit.SqliteMigrations.Migrations
|
||||
b.Property<Guid?>("ProviderUserId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid?>("SecretId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<Guid?>("ServiceAccountId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<byte?>("SystemUser")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
|
Reference in New Issue
Block a user