mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 16:12:49 -05:00
[SM-394] Secrets Manager (#2164)
Long lived feature branch for Secrets Manager Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com> Co-authored-by: cd-bitwarden <106776772+cd-bitwarden@users.noreply.github.com> Co-authored-by: CarleyDiaz-Bitwarden <103955722+CarleyDiaz-Bitwarden@users.noreply.github.com> Co-authored-by: Thomas Avery <tavery@bitwarden.com> Co-authored-by: Colton Hurst <colton@coltonhurst.com>
This commit is contained in:
@ -17,7 +17,6 @@ using Bit.Core.Settings;
|
||||
using Bit.Core.Tokens;
|
||||
using Bit.Core.Utilities;
|
||||
using Bit.Infrastructure.Dapper;
|
||||
using Bit.Infrastructure.EntityFramework;
|
||||
using IdentityModel;
|
||||
using IdentityServer4.AccessTokenValidation;
|
||||
using IdentityServer4.Configuration;
|
||||
@ -52,6 +51,7 @@ public static class ServiceCollectionExtensions
|
||||
var selectedDatabaseProvider = globalSettings.DatabaseProvider;
|
||||
var provider = SupportedDatabaseProviders.SqlServer;
|
||||
var connectionString = string.Empty;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(selectedDatabaseProvider))
|
||||
{
|
||||
switch (selectedDatabaseProvider.ToLowerInvariant())
|
||||
@ -70,16 +70,24 @@ public static class ServiceCollectionExtensions
|
||||
provider = SupportedDatabaseProviders.Sqlite;
|
||||
connectionString = globalSettings.Sqlite.ConnectionString;
|
||||
break;
|
||||
case "sqlserver":
|
||||
connectionString = globalSettings.SqlServer.ConnectionString;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var useEf = (provider != SupportedDatabaseProviders.SqlServer);
|
||||
|
||||
if (useEf)
|
||||
else
|
||||
{
|
||||
services.AddEFRepositories(globalSettings.SelfHosted, connectionString, provider);
|
||||
// Default to attempting to use SqlServer connection string if globalSettings.DatabaseProvider has no value.
|
||||
connectionString = globalSettings.SqlServer.ConnectionString;
|
||||
}
|
||||
|
||||
services.SetupEntityFramework(connectionString, provider);
|
||||
|
||||
if (provider != SupportedDatabaseProviders.SqlServer)
|
||||
{
|
||||
services.AddPasswordManagerEFRepositories(globalSettings.SelfHosted);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -337,9 +345,9 @@ public static class ServiceCollectionExtensions
|
||||
};
|
||||
options.ClaimsIdentity = new ClaimsIdentityOptions
|
||||
{
|
||||
SecurityStampClaimType = "sstamp",
|
||||
SecurityStampClaimType = Claims.SecurityStamp,
|
||||
UserNameClaimType = JwtClaimTypes.Email,
|
||||
UserIdClaimType = JwtClaimTypes.Subject
|
||||
UserIdClaimType = JwtClaimTypes.Subject,
|
||||
};
|
||||
options.Tokens.ChangeEmailTokenProvider = TokenOptions.DefaultEmailProvider;
|
||||
});
|
||||
@ -623,7 +631,7 @@ public static class ServiceCollectionExtensions
|
||||
services.AddSingleton<IConnectionMultiplexer>(
|
||||
_ => ConnectionMultiplexer.Connect(globalSettings.Redis.ConnectionString));
|
||||
|
||||
// Explicitly register IDistributedCache to re-use existing IConnectionMultiplexer
|
||||
// Explicitly register IDistributedCache to re-use existing IConnectionMultiplexer
|
||||
// to reduce the number of redundant connections to the Redis instance
|
||||
services.AddSingleton<IDistributedCache>(s =>
|
||||
{
|
||||
|
@ -539,6 +539,15 @@
|
||||
"Microsoft.Extensions.DependencyModel": "6.0.0"
|
||||
}
|
||||
},
|
||||
"Microsoft.EntityFrameworkCore.SqlServer": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.0.12",
|
||||
"contentHash": "bdKnSz1w+WZz9QYWhs3wwGuMn4YssjdR+HOBpzChQ6C3+dblq4Pammm5fzugcPOhTgCiWftOT2jPOT5hEy4bYg==",
|
||||
"dependencies": {
|
||||
"Microsoft.Data.SqlClient": "2.1.4",
|
||||
"Microsoft.EntityFrameworkCore.Relational": "6.0.12"
|
||||
}
|
||||
},
|
||||
"Microsoft.Extensions.Caching.Abstractions": {
|
||||
"type": "Transitive",
|
||||
"resolved": "6.0.0",
|
||||
@ -2754,6 +2763,7 @@
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "[11.0.0, )",
|
||||
"Core": "[2022.12.0, )",
|
||||
"Microsoft.EntityFrameworkCore.Relational": "[6.0.12, )",
|
||||
"Microsoft.EntityFrameworkCore.SqlServer": "[6.0.12, )",
|
||||
"Microsoft.EntityFrameworkCore.Sqlite": "[6.0.12, )",
|
||||
"Npgsql.EntityFrameworkCore.PostgreSQL": "[6.0.8, )",
|
||||
"Pomelo.EntityFrameworkCore.MySql": "[6.0.2, )",
|
||||
|
Reference in New Issue
Block a user