mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 08:32:50 -05:00
Merge branch 'master' into feature/families-for-enterprise
This commit is contained in:
420
util/Migrator/DbScripts/2021-11-12_00_KeyConnectorFlag.sql
Normal file
420
util/Migrator/DbScripts/2021-11-12_00_KeyConnectorFlag.sql
Normal file
@ -0,0 +1,420 @@
|
||||
IF COL_LENGTH('[dbo].[Organization]', 'UseKeyConnector') IS NULL
|
||||
BEGIN
|
||||
ALTER TABLE
|
||||
[dbo].[Organization]
|
||||
ADD
|
||||
[UseKeyConnector] BIT NULL
|
||||
END
|
||||
GO
|
||||
|
||||
UPDATE
|
||||
[dbo].[Organization]
|
||||
SET
|
||||
[UseKeyConnector] = 0
|
||||
WHERE
|
||||
[UseKeyConnector] IS NULL
|
||||
GO
|
||||
|
||||
ALTER TABLE
|
||||
[dbo].[Organization]
|
||||
ALTER COLUMN
|
||||
[UseKeyConnector] BIT NOT NULL
|
||||
GO
|
||||
|
||||
IF EXISTS(SELECT * FROM sys.views WHERE [Name] = 'OrganizationView')
|
||||
BEGIN
|
||||
DROP VIEW [dbo].[OrganizationView]
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE VIEW [dbo].[OrganizationView]
|
||||
AS
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[Organization]
|
||||
GO
|
||||
|
||||
IF OBJECT_ID('[dbo].[Organization_Create]') IS NOT NULL
|
||||
BEGIN
|
||||
DROP PROCEDURE [dbo].[Organization_Create]
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[Organization_Create]
|
||||
@Id UNIQUEIDENTIFIER OUTPUT,
|
||||
@Identifier NVARCHAR(50),
|
||||
@Name NVARCHAR(50),
|
||||
@BusinessName NVARCHAR(50),
|
||||
@BusinessAddress1 NVARCHAR(50),
|
||||
@BusinessAddress2 NVARCHAR(50),
|
||||
@BusinessAddress3 NVARCHAR(50),
|
||||
@BusinessCountry VARCHAR(2),
|
||||
@BusinessTaxNumber NVARCHAR(30),
|
||||
@BillingEmail NVARCHAR(256),
|
||||
@Plan NVARCHAR(50),
|
||||
@PlanType TINYINT,
|
||||
@Seats INT,
|
||||
@MaxCollections SMALLINT,
|
||||
@UsePolicies BIT,
|
||||
@UseSso BIT,
|
||||
@UseGroups BIT,
|
||||
@UseDirectory BIT,
|
||||
@UseEvents BIT,
|
||||
@UseTotp BIT,
|
||||
@Use2fa BIT,
|
||||
@UseApi BIT,
|
||||
@UseResetPassword BIT,
|
||||
@SelfHost BIT,
|
||||
@UsersGetPremium BIT,
|
||||
@Storage BIGINT,
|
||||
@MaxStorageGb SMALLINT,
|
||||
@Gateway TINYINT,
|
||||
@GatewayCustomerId VARCHAR(50),
|
||||
@GatewaySubscriptionId VARCHAR(50),
|
||||
@ReferenceData VARCHAR(MAX),
|
||||
@Enabled BIT,
|
||||
@LicenseKey VARCHAR(100),
|
||||
@ApiKey VARCHAR(30),
|
||||
@PublicKey VARCHAR(MAX),
|
||||
@PrivateKey VARCHAR(MAX),
|
||||
@TwoFactorProviders NVARCHAR(MAX),
|
||||
@ExpirationDate DATETIME2(7),
|
||||
@CreationDate DATETIME2(7),
|
||||
@RevisionDate DATETIME2(7),
|
||||
@OwnersNotifiedOfAutoscaling DATETIME2(7),
|
||||
@MaxAutoscaleSeats INT,
|
||||
@UseKeyConnector BIT = 0
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
INSERT INTO [dbo].[Organization]
|
||||
(
|
||||
[Id],
|
||||
[Identifier],
|
||||
[Name],
|
||||
[BusinessName],
|
||||
[BusinessAddress1],
|
||||
[BusinessAddress2],
|
||||
[BusinessAddress3],
|
||||
[BusinessCountry],
|
||||
[BusinessTaxNumber],
|
||||
[BillingEmail],
|
||||
[Plan],
|
||||
[PlanType],
|
||||
[Seats],
|
||||
[MaxCollections],
|
||||
[UsePolicies],
|
||||
[UseSso],
|
||||
[UseGroups],
|
||||
[UseDirectory],
|
||||
[UseEvents],
|
||||
[UseTotp],
|
||||
[Use2fa],
|
||||
[UseApi],
|
||||
[UseResetPassword],
|
||||
[SelfHost],
|
||||
[UsersGetPremium],
|
||||
[Storage],
|
||||
[MaxStorageGb],
|
||||
[Gateway],
|
||||
[GatewayCustomerId],
|
||||
[GatewaySubscriptionId],
|
||||
[ReferenceData],
|
||||
[Enabled],
|
||||
[LicenseKey],
|
||||
[ApiKey],
|
||||
[PublicKey],
|
||||
[PrivateKey],
|
||||
[TwoFactorProviders],
|
||||
[ExpirationDate],
|
||||
[CreationDate],
|
||||
[RevisionDate],
|
||||
[OwnersNotifiedOfAutoscaling],
|
||||
[MaxAutoscaleSeats],
|
||||
[UseKeyConnector]
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
@Id,
|
||||
@Identifier,
|
||||
@Name,
|
||||
@BusinessName,
|
||||
@BusinessAddress1,
|
||||
@BusinessAddress2,
|
||||
@BusinessAddress3,
|
||||
@BusinessCountry,
|
||||
@BusinessTaxNumber,
|
||||
@BillingEmail,
|
||||
@Plan,
|
||||
@PlanType,
|
||||
@Seats,
|
||||
@MaxCollections,
|
||||
@UsePolicies,
|
||||
@UseSso,
|
||||
@UseGroups,
|
||||
@UseDirectory,
|
||||
@UseEvents,
|
||||
@UseTotp,
|
||||
@Use2fa,
|
||||
@UseApi,
|
||||
@UseResetPassword,
|
||||
@SelfHost,
|
||||
@UsersGetPremium,
|
||||
@Storage,
|
||||
@MaxStorageGb,
|
||||
@Gateway,
|
||||
@GatewayCustomerId,
|
||||
@GatewaySubscriptionId,
|
||||
@ReferenceData,
|
||||
@Enabled,
|
||||
@LicenseKey,
|
||||
@ApiKey,
|
||||
@PublicKey,
|
||||
@PrivateKey,
|
||||
@TwoFactorProviders,
|
||||
@ExpirationDate,
|
||||
@CreationDate,
|
||||
@RevisionDate,
|
||||
@OwnersNotifiedOfAutoscaling,
|
||||
@MaxAutoscaleSeats,
|
||||
@UseKeyConnector
|
||||
)
|
||||
END
|
||||
GO
|
||||
|
||||
IF OBJECT_ID('[dbo].[Organization_ReadAbilities]') IS NOT NULL
|
||||
BEGIN
|
||||
DROP PROCEDURE [dbo].[Organization_ReadAbilities]
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[Organization_ReadAbilities]
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT
|
||||
[Id],
|
||||
[UseEvents],
|
||||
[Use2fa],
|
||||
CASE
|
||||
WHEN [Use2fa] = 1 AND [TwoFactorProviders] IS NOT NULL AND [TwoFactorProviders] != '{}' THEN
|
||||
1
|
||||
ELSE
|
||||
0
|
||||
END AS [Using2fa],
|
||||
[UsersGetPremium],
|
||||
[UseSso],
|
||||
[UseKeyConnector],
|
||||
[UseResetPassword],
|
||||
[Enabled]
|
||||
FROM
|
||||
[dbo].[Organization]
|
||||
END
|
||||
GO
|
||||
|
||||
IF OBJECT_ID('[dbo].[Organization_Update]') IS NOT NULL
|
||||
BEGIN
|
||||
DROP PROCEDURE [dbo].[Organization_Update]
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE PROCEDURE [dbo].[Organization_Update]
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@Identifier NVARCHAR(50),
|
||||
@Name NVARCHAR(50),
|
||||
@BusinessName NVARCHAR(50),
|
||||
@BusinessAddress1 NVARCHAR(50),
|
||||
@BusinessAddress2 NVARCHAR(50),
|
||||
@BusinessAddress3 NVARCHAR(50),
|
||||
@BusinessCountry VARCHAR(2),
|
||||
@BusinessTaxNumber NVARCHAR(30),
|
||||
@BillingEmail NVARCHAR(256),
|
||||
@Plan NVARCHAR(50),
|
||||
@PlanType TINYINT,
|
||||
@Seats INT,
|
||||
@MaxCollections SMALLINT,
|
||||
@UsePolicies BIT,
|
||||
@UseSso BIT,
|
||||
@UseGroups BIT,
|
||||
@UseDirectory BIT,
|
||||
@UseEvents BIT,
|
||||
@UseTotp BIT,
|
||||
@Use2fa BIT,
|
||||
@UseApi BIT,
|
||||
@UseResetPassword BIT,
|
||||
@SelfHost BIT,
|
||||
@UsersGetPremium BIT,
|
||||
@Storage BIGINT,
|
||||
@MaxStorageGb SMALLINT,
|
||||
@Gateway TINYINT,
|
||||
@GatewayCustomerId VARCHAR(50),
|
||||
@GatewaySubscriptionId VARCHAR(50),
|
||||
@ReferenceData VARCHAR(MAX),
|
||||
@Enabled BIT,
|
||||
@LicenseKey VARCHAR(100),
|
||||
@ApiKey VARCHAR(30),
|
||||
@PublicKey VARCHAR(MAX),
|
||||
@PrivateKey VARCHAR(MAX),
|
||||
@TwoFactorProviders NVARCHAR(MAX),
|
||||
@ExpirationDate DATETIME2(7),
|
||||
@CreationDate DATETIME2(7),
|
||||
@RevisionDate DATETIME2(7),
|
||||
@OwnersNotifiedOfAutoscaling DATETIME2(7),
|
||||
@MaxAutoscaleSeats INT,
|
||||
@UseKeyConnector BIT = 0
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
UPDATE
|
||||
[dbo].[Organization]
|
||||
SET
|
||||
[Identifier] = @Identifier,
|
||||
[Name] = @Name,
|
||||
[BusinessName] = @BusinessName,
|
||||
[BusinessAddress1] = @BusinessAddress1,
|
||||
[BusinessAddress2] = @BusinessAddress2,
|
||||
[BusinessAddress3] = @BusinessAddress3,
|
||||
[BusinessCountry] = @BusinessCountry,
|
||||
[BusinessTaxNumber] = @BusinessTaxNumber,
|
||||
[BillingEmail] = @BillingEmail,
|
||||
[Plan] = @Plan,
|
||||
[PlanType] = @PlanType,
|
||||
[Seats] = @Seats,
|
||||
[MaxCollections] = @MaxCollections,
|
||||
[UsePolicies] = @UsePolicies,
|
||||
[UseSso] = @UseSso,
|
||||
[UseGroups] = @UseGroups,
|
||||
[UseDirectory] = @UseDirectory,
|
||||
[UseEvents] = @UseEvents,
|
||||
[UseTotp] = @UseTotp,
|
||||
[Use2fa] = @Use2fa,
|
||||
[UseApi] = @UseApi,
|
||||
[UseResetPassword] = @UseResetPassword,
|
||||
[SelfHost] = @SelfHost,
|
||||
[UsersGetPremium] = @UsersGetPremium,
|
||||
[Storage] = @Storage,
|
||||
[MaxStorageGb] = @MaxStorageGb,
|
||||
[Gateway] = @Gateway,
|
||||
[GatewayCustomerId] = @GatewayCustomerId,
|
||||
[GatewaySubscriptionId] = @GatewaySubscriptionId,
|
||||
[ReferenceData] = @ReferenceData,
|
||||
[Enabled] = @Enabled,
|
||||
[LicenseKey] = @LicenseKey,
|
||||
[ApiKey] = @ApiKey,
|
||||
[PublicKey] = @PublicKey,
|
||||
[PrivateKey] = @PrivateKey,
|
||||
[TwoFactorProviders] = @TwoFactorProviders,
|
||||
[ExpirationDate] = @ExpirationDate,
|
||||
[CreationDate] = @CreationDate,
|
||||
[RevisionDate] = @RevisionDate,
|
||||
[OwnersNotifiedOfAutoscaling] = @OwnersNotifiedOfAutoscaling,
|
||||
[MaxAutoscaleSeats] = @MaxAutoscaleSeats,
|
||||
[UseKeyConnector] = @UseKeyConnector
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
END
|
||||
GO
|
||||
|
||||
IF EXISTS(SELECT * FROM sys.views WHERE [Name] = 'OrganizationUserOrganizationDetailsView')
|
||||
BEGIN
|
||||
DROP VIEW [dbo].[OrganizationUserOrganizationDetailsView]
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE VIEW [dbo].[OrganizationUserOrganizationDetailsView]
|
||||
AS
|
||||
SELECT
|
||||
OU.[UserId],
|
||||
OU.[OrganizationId],
|
||||
O.[Name],
|
||||
O.[Enabled],
|
||||
O.[UsePolicies],
|
||||
O.[UseSso],
|
||||
O.[UseKeyConnector],
|
||||
O.[UseGroups],
|
||||
O.[UseDirectory],
|
||||
O.[UseEvents],
|
||||
O.[UseTotp],
|
||||
O.[Use2fa],
|
||||
O.[UseApi],
|
||||
O.[UseResetPassword],
|
||||
O.[SelfHost],
|
||||
O.[UsersGetPremium],
|
||||
O.[Seats],
|
||||
O.[MaxCollections],
|
||||
O.[MaxStorageGb],
|
||||
O.[Identifier],
|
||||
OU.[Key],
|
||||
OU.[ResetPasswordKey],
|
||||
O.[PublicKey],
|
||||
O.[PrivateKey],
|
||||
OU.[Status],
|
||||
OU.[Type],
|
||||
SU.[ExternalId] SsoExternalId,
|
||||
OU.[Permissions],
|
||||
PO.[ProviderId],
|
||||
P.[Name] ProviderName,
|
||||
SS.[Data] SsoConfig
|
||||
FROM
|
||||
[dbo].[OrganizationUser] OU
|
||||
INNER JOIN
|
||||
[dbo].[Organization] O ON O.[Id] = OU.[OrganizationId]
|
||||
LEFT JOIN
|
||||
[dbo].[SsoUser] SU ON SU.[UserId] = OU.[UserId] AND SU.[OrganizationId] = OU.[OrganizationId]
|
||||
LEFT JOIN
|
||||
[dbo].[ProviderOrganization] PO ON PO.[OrganizationId] = O.[Id]
|
||||
LEFT JOIN
|
||||
[dbo].[Provider] P ON P.[Id] = PO.[ProviderId]
|
||||
LEFT JOIN
|
||||
[dbo].[SsoConfig] SS ON SS.[OrganizationId] = OU.[OrganizationId]
|
||||
GO
|
||||
|
||||
IF OBJECT_ID('[dbo].[ProviderUserProviderOrganizationDetailsView]') IS NOT NULL
|
||||
BEGIN
|
||||
DROP VIEW [dbo].[ProviderUserProviderOrganizationDetailsView]
|
||||
END
|
||||
GO
|
||||
|
||||
CREATE VIEW [dbo].[ProviderUserProviderOrganizationDetailsView]
|
||||
AS
|
||||
SELECT
|
||||
PU.[UserId],
|
||||
PO.[OrganizationId],
|
||||
O.[Name],
|
||||
O.[Enabled],
|
||||
O.[UsePolicies],
|
||||
O.[UseSso],
|
||||
O.[UseKeyConnector],
|
||||
O.[UseGroups],
|
||||
O.[UseDirectory],
|
||||
O.[UseEvents],
|
||||
O.[UseTotp],
|
||||
O.[Use2fa],
|
||||
O.[UseApi],
|
||||
O.[UseResetPassword],
|
||||
O.[SelfHost],
|
||||
O.[UsersGetPremium],
|
||||
O.[Seats],
|
||||
O.[MaxCollections],
|
||||
O.[MaxStorageGb],
|
||||
O.[Identifier],
|
||||
PO.[Key],
|
||||
O.[PublicKey],
|
||||
O.[PrivateKey],
|
||||
PU.[Status],
|
||||
PU.[Type],
|
||||
PO.[ProviderId],
|
||||
PU.[Id] ProviderUserId,
|
||||
P.[Name] ProviderName
|
||||
FROM
|
||||
[dbo].[ProviderUser] PU
|
||||
INNER JOIN
|
||||
[dbo].[ProviderOrganization] PO ON PO.[ProviderId] = PU.[ProviderId]
|
||||
INNER JOIN
|
||||
[dbo].[Organization] O ON O.[Id] = PO.[OrganizationId]
|
||||
INNER JOIN
|
||||
[dbo].[Provider] P ON P.[Id] = PU.[ProviderId]
|
@ -14,6 +14,7 @@ SELECT
|
||||
O.[PlanType],
|
||||
O.[UsePolicies],
|
||||
O.[UseSso],
|
||||
O.[UserKeyConnector],
|
||||
O.[UseGroups],
|
||||
O.[UseDirectory],
|
||||
O.[UseEvents],
|
||||
@ -53,3 +54,4 @@ LEFT JOIN
|
||||
[dbo].[SsoConfig] SS ON SS.[OrganizationId] = OU.[OrganizationId]
|
||||
LEFT JOIN
|
||||
[dbo].[OrganizationSponsorship] OS ON OS.[SponsoringOrganizationUserID] = OU.[Id]
|
||||
GO
|
1498
util/MySqlMigrations/Migrations/20211115145402_KeyConnectorFlag.Designer.cs
generated
Normal file
1498
util/MySqlMigrations/Migrations/20211115145402_KeyConnectorFlag.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Bit.MySqlMigrations.Migrations
|
||||
{
|
||||
public partial class KeyConnectorFlag : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "UseKeyConnector",
|
||||
table: "Organization",
|
||||
type: "tinyint(1)",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "UseKeyConnector",
|
||||
table: "Organization");
|
||||
}
|
||||
}
|
||||
}
|
@ -565,6 +565,9 @@ namespace Bit.MySqlMigrations.Migrations
|
||||
b.Property<bool>("UseGroups")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("UseKeyConnector")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<bool>("UsePolicies")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<UserSecretsId>9f1cd3e0-70f2-4921-8068-b2538fd7c3f7</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
BIN
util/MySqlMigrations/Scripts/2021-11-12_00_KeyConnectorFlag.sql
Normal file
BIN
util/MySqlMigrations/Scripts/2021-11-12_00_KeyConnectorFlag.sql
Normal file
Binary file not shown.
1507
util/PostgresMigrations/Migrations/20211115142623_KeyConnectorFlag.Designer.cs
generated
Normal file
1507
util/PostgresMigrations/Migrations/20211115142623_KeyConnectorFlag.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Bit.PostgresMigrations.Migrations
|
||||
{
|
||||
public partial class KeyConnectorFlag : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "UseKeyConnector",
|
||||
table: "Organization",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "UseKeyConnector",
|
||||
table: "Organization");
|
||||
}
|
||||
}
|
||||
}
|
@ -569,6 +569,9 @@ namespace Bit.PostgresMigrations.Migrations
|
||||
b.Property<bool>("UseGroups")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("UseKeyConnector")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("UsePolicies")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
|
Binary file not shown.
@ -97,5 +97,19 @@ namespace Bit.Setup
|
||||
Helpers.ShowBanner(_context, "WARNING", message, ConsoleColor.Yellow);
|
||||
}
|
||||
}
|
||||
|
||||
public void BuildForUpdater()
|
||||
{
|
||||
if (_context.Config.EnableKeyConnector && !File.Exists("/bitwarden/key-connector/bwkc.pfx"))
|
||||
{
|
||||
Directory.CreateDirectory("/bitwarden/key-connector/");
|
||||
var keyConnectorCertPassword = Helpers.GetValueFromEnvFile("key-connector",
|
||||
"keyConnectorSettings__certificate__filesystemPassword");
|
||||
Helpers.Exec("openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout bwkc.key " +
|
||||
"-out bwkc.crt -subj \"/CN=Bitwarden Key Connector\" -days 36500");
|
||||
Helpers.Exec("openssl pkcs12 -export -out /bitwarden/key-connector/bwkc.pfx -inkey bwkc.key " +
|
||||
$"-in bwkc.crt -passout pass:{keyConnectorCertPassword}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,6 +100,9 @@ namespace Bit.Setup
|
||||
"Learn more: https://nginx.org/en/docs/http/ngx_http_realip_module.html")]
|
||||
public List<string> RealIps { get; set; }
|
||||
|
||||
[Description("Enable Key Connector (https://bitwarden.com/help/article/deploy-key-connector)")]
|
||||
public bool EnableKeyConnector { get; set; } = false;
|
||||
|
||||
[YamlIgnore]
|
||||
public string Domain
|
||||
{
|
||||
|
@ -50,6 +50,7 @@ namespace Bit.Setup
|
||||
ComposeVersion = context.Config.ComposeVersion;
|
||||
}
|
||||
MssqlDataDockerVolume = context.Config.DatabaseDockerVolume;
|
||||
EnableKeyConnector = context.Config.EnableKeyConnector;
|
||||
HttpPort = context.Config.HttpPort;
|
||||
HttpsPort = context.Config.HttpsPort;
|
||||
if (!string.IsNullOrWhiteSpace(context.CoreVersion))
|
||||
@ -64,6 +65,7 @@ namespace Bit.Setup
|
||||
|
||||
public string ComposeVersion { get; set; } = "3";
|
||||
public bool MssqlDataDockerVolume { get; set; }
|
||||
public bool EnableKeyConnector { get; set; }
|
||||
public string HttpPort { get; set; }
|
||||
public string HttpsPort { get; set; }
|
||||
public bool HasPort => !string.IsNullOrWhiteSpace(HttpPort) || !string.IsNullOrWhiteSpace(HttpsPort);
|
||||
|
@ -14,6 +14,7 @@ namespace Bit.Setup
|
||||
private IDictionary<string, string> _mssqlValues;
|
||||
private IDictionary<string, string> _globalOverrideValues;
|
||||
private IDictionary<string, string> _mssqlOverrideValues;
|
||||
private IDictionary<string, string> _keyConnectorOverrideValues;
|
||||
|
||||
public EnvironmentFileBuilder(Context context)
|
||||
{
|
||||
@ -45,6 +46,7 @@ namespace Bit.Setup
|
||||
Init();
|
||||
LoadExistingValues(_globalOverrideValues, "/bitwarden/env/global.override.env");
|
||||
LoadExistingValues(_mssqlOverrideValues, "/bitwarden/env/mssql.override.env");
|
||||
LoadExistingValues(_keyConnectorOverrideValues, "/bitwarden/env/key-connector.override.env");
|
||||
|
||||
if (_context.Config.PushNotifications &&
|
||||
_globalOverrideValues.ContainsKey("globalSettings__pushRelayBaseUri") &&
|
||||
@ -107,6 +109,18 @@ namespace Bit.Setup
|
||||
{
|
||||
["SA_PASSWORD"] = dbPassword,
|
||||
};
|
||||
|
||||
_keyConnectorOverrideValues = new Dictionary<string, string>
|
||||
{
|
||||
["keyConnectorSettings__webVaultUri"] = _context.Config.Url,
|
||||
["keyConnectorSettings__identityServerUri"] = "http://identity:5000",
|
||||
["keyConnectorSettings__database__provider"] = "json",
|
||||
["keyConnectorSettings__database__jsonFilePath"] = "/etc/bitwarden/key-connector/data.json",
|
||||
["keyConnectorSettings__rsaKey__provider"] = "certificate",
|
||||
["keyConnectorSettings__certificate__provider"] = "filesystem",
|
||||
["keyConnectorSettings__certificate__filesystemPath"] = "/etc/bitwarden/key-connector/bwkc.pfx",
|
||||
["keyConnectorSettings__certificate__filesystemPassword"] = Helpers.SecureRandomString(32, alpha: true, numeric: true),
|
||||
};
|
||||
}
|
||||
|
||||
private void LoadExistingValues(IDictionary<string, string> _values, string file)
|
||||
@ -179,6 +193,16 @@ namespace Bit.Setup
|
||||
}
|
||||
Helpers.Exec("chmod 600 /bitwarden/env/mssql.override.env");
|
||||
|
||||
if (_context.Config.EnableKeyConnector)
|
||||
{
|
||||
using (var sw = File.CreateText("/bitwarden/env/key-connector.override.env"))
|
||||
{
|
||||
sw.Write(template(new TemplateModel(_keyConnectorOverrideValues)));
|
||||
}
|
||||
|
||||
Helpers.Exec("chmod 600 /bitwarden/env/key-connector.override.env");
|
||||
}
|
||||
|
||||
// Empty uid env file. Only used on Linux hosts.
|
||||
if (!File.Exists("/bitwarden/env/uid.env"))
|
||||
{
|
||||
|
@ -70,6 +70,7 @@ namespace Bit.Setup
|
||||
{
|
||||
Captcha = context.Config.Captcha;
|
||||
Ssl = context.Config.Ssl;
|
||||
EnableKeyConnector = context.Config.EnableKeyConnector;
|
||||
Domain = context.Config.Domain;
|
||||
Url = context.Config.Url;
|
||||
RealIps = context.Config.RealIps;
|
||||
@ -117,6 +118,7 @@ namespace Bit.Setup
|
||||
|
||||
public bool Captcha { get; set; }
|
||||
public bool Ssl { get; set; }
|
||||
public bool EnableKeyConnector { get; set; }
|
||||
public string Domain { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string CertificatePath { get; set; }
|
||||
|
@ -291,6 +291,9 @@ namespace Bit.Setup
|
||||
|
||||
var environmentFileBuilder = new EnvironmentFileBuilder(_context);
|
||||
environmentFileBuilder.BuildForUpdater();
|
||||
|
||||
var certBuilder = new CertBuilder(_context);
|
||||
certBuilder.BuildForUpdater();
|
||||
|
||||
var nginxBuilder = new NginxConfigBuilder(_context);
|
||||
nginxBuilder.BuildForUpdater();
|
||||
|
@ -194,6 +194,22 @@ services:
|
||||
networks:
|
||||
- default
|
||||
- public
|
||||
|
||||
{{#if EnableKeyConnector}}
|
||||
key-connector:
|
||||
image: bitwarden/key-connector:latest
|
||||
container_name: bitwarden-key-connector
|
||||
restart: always
|
||||
volumes:
|
||||
- ../key-connector:/etc/bitwarden/key-connector
|
||||
- ../ca-certificates:/etc/bitwarden/ca-certificates
|
||||
- ../logs/key-connector:/etc/bitwarden/logs
|
||||
env_file:
|
||||
- ../env/key-connector.override.env
|
||||
networks:
|
||||
- default
|
||||
- public
|
||||
{{/if}}
|
||||
{{#if MssqlDataDockerVolume}}
|
||||
|
||||
volumes:
|
||||
|
@ -166,4 +166,10 @@ server {
|
||||
include /etc/nginx/security-headers.conf;
|
||||
add_header X-Frame-Options SAMEORIGIN;
|
||||
}
|
||||
|
||||
{{#if EnableKeyConnector}}
|
||||
location /key-connector/ {
|
||||
proxy_pass http://key-connector:5000/;
|
||||
}
|
||||
{{/if}}
|
||||
}
|
||||
|
Reference in New Issue
Block a user