mirror of
https://github.com/bitwarden/server.git
synced 2025-05-28 23:04:50 -05:00
only load idserv cert in prod environment
This commit is contained in:
parent
6cde9ed223
commit
77e54f7c12
@ -50,9 +50,11 @@ namespace Bit.Api
|
|||||||
builder.AddEnvironmentVariables();
|
builder.AddEnvironmentVariables();
|
||||||
|
|
||||||
Configuration = builder.Build();
|
Configuration = builder.Build();
|
||||||
|
Environment = env;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IConfigurationRoot Configuration { get; private set; }
|
public IConfigurationRoot Configuration { get; private set; }
|
||||||
|
public IHostingEnvironment Environment { get; set; }
|
||||||
|
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
@ -87,11 +89,20 @@ namespace Bit.Api
|
|||||||
services.AddSingleton<IRateLimitCounterStore, MemoryCacheRateLimitCounterStore>();
|
services.AddSingleton<IRateLimitCounterStore, MemoryCacheRateLimitCounterStore>();
|
||||||
|
|
||||||
// IdentityServer
|
// IdentityServer
|
||||||
var identityServerCert = CoreHelpers.GetCertificate(globalSettings.IdentityServer.CertificateThumbprint);
|
var identityServerBuilder = services.AddIdentityServer()
|
||||||
services.AddIdentityServer()
|
|
||||||
.AddSigningCredential(identityServerCert)
|
|
||||||
.AddInMemoryApiResources(ApiResources.GetApiResources())
|
.AddInMemoryApiResources(ApiResources.GetApiResources())
|
||||||
.AddInMemoryClients(Clients.GetClients());
|
.AddInMemoryClients(Clients.GetClients());
|
||||||
|
|
||||||
|
if(Environment.IsProduction())
|
||||||
|
{
|
||||||
|
var identityServerCert = CoreHelpers.GetCertificate(globalSettings.IdentityServer.CertificateThumbprint);
|
||||||
|
identityServerBuilder.AddSigningCredential(identityServerCert);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
identityServerBuilder.AddTemporarySigningCredential();
|
||||||
|
}
|
||||||
|
|
||||||
services.AddSingleton<IResourceOwnerPasswordValidator, ResourceOwnerPasswordValidator>();
|
services.AddSingleton<IResourceOwnerPasswordValidator, ResourceOwnerPasswordValidator>();
|
||||||
services.AddSingleton<IProfileService, ProfileService>();
|
services.AddSingleton<IProfileService, ProfileService>();
|
||||||
services.AddSingleton<IPersistedGrantStore, PersistedGrantStore>();
|
services.AddSingleton<IPersistedGrantStore, PersistedGrantStore>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user