aboutsummaryrefslogtreecommitdiffstats
path: root/src/server/Startup.cs
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2020-08-10 21:35:58 +0200
committerivarlovlie <git@ivarlovlie.no>2020-08-10 21:35:58 +0200
commit2cfee78597971b2e3e7e612eb9d7e8805e1aef85 (patch)
treeb939d48347c7fff48d2a51761cb546c3b9ac6ec0 /src/server/Startup.cs
parent8614d18522441543e08c37c68121fed1fa8d6ae7 (diff)
downloaddough-2cfee78597971b2e3e7e612eb9d7e8805e1aef85.tar.xz
dough-2cfee78597971b2e3e7e612eb9d7e8805e1aef85.zip
add signing credentials
Diffstat (limited to 'src/server/Startup.cs')
-rw-r--r--src/server/Startup.cs19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/server/Startup.cs b/src/server/Startup.cs
index 891965b..7ebe86b 100644
--- a/src/server/Startup.cs
+++ b/src/server/Startup.cs
@@ -1,4 +1,5 @@
using System.IO;
+using System.Security.Cryptography.X509Certificates;
using Dough.IdentityServer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
@@ -11,8 +12,6 @@ using Dough.Models.Database;
using Dough.Services;
using IdentityServer4.Configuration;
using Microsoft.AspNetCore.DataProtection;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
namespace Dough
{
@@ -30,13 +29,19 @@ namespace Dough
private string GetConnectionStringFromEnvironment()
{
var host = Configuration.GetValue<string>("DB_HOST");
- var port = Configuration.GetValue("DB_PORT", "3306");
+ var port = Configuration.GetValue<string>("DB_PORT");
var user = Configuration.GetValue<string>("DB_USER");
var password = Configuration.GetValue<string>("DB_PASSWORD");
var name = Configuration.GetValue<string>("DB_NAME");
return $"Server={host},{port};Database={name};User={user};Password={password}";
}
+ private X509Certificate2 GetSigningCredentialFromPfx(string fileName)
+ {
+ var path = Path.Combine(Directory.GetCurrentDirectory(), "AppData", fileName);
+ return new X509Certificate2(path, string.Empty);
+ }
+
public void ConfigureServices(IServiceCollection services)
{
services.AddCors(options =>
@@ -46,8 +51,7 @@ namespace Dough
builder
.WithOrigins(Constants.BrowserAppUrls)
.AllowAnyHeader()
- .AllowAnyMethod()
- .AllowCredentials();
+ .AllowAnyMethod();
});
});
@@ -72,7 +76,9 @@ namespace Dough
})
.AddInMemoryIdentityResources(Config.IdentityResources)
.AddInMemoryApiScopes(Config.ApiScopes)
- .AddDeveloperSigningCredential()
+ .AddSigningCredential(GetSigningCredentialFromPfx("example.pfx"))
+ .AddValidationKey(GetSigningCredentialFromPfx("example2.pfx"))
+ .AddProfileService<ProfileService>()
.AddInMemoryClients(Config.Clients);
services.AddSingleton<EmailService>();
@@ -87,6 +93,7 @@ namespace Dough
app.UseDeveloperExceptionPage();
app.UseRouting();
+ app.UseStaticFiles();
app.UseCors(DefaultCorsPolicy);
app.UseHealthChecks("/health");
app.UseStatusCodePages();