Skip to content

Commit

Permalink
Remove HPKP from sample, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
joonaszure committed Mar 3, 2022
1 parent a582ebd commit 3812c92
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<!--<TargetFramework>netcoreapp3.1</TargetFramework>-->
<!--<TargetFramework>net5.0</TargetFramework>-->
<TargetFramework>net6.0</TargetFramework>
<UserSecretsId>33ce3d09-4099-4a8e-93af-049b12b6eb90</UserSecretsId>
</PropertyGroup>
<ItemGroup>
Expand Down
19 changes: 5 additions & 14 deletions test/Joonasw.AspNetCore.SecurityHeaders.Samples/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace Joonasw.AspNetCore.SecurityHeaders.Samples
{
// ReSharper disable once ClassNeverInstantiated.Global
public class Startup
{
public Startup(IConfiguration configuration)
public Startup(IConfiguration configuration, IWebHostEnvironment environment)
{
Configuration = configuration;
Environment = environment;
}

private IConfiguration Configuration { get; }
private IWebHostEnvironment Environment { get; }

public void ConfigureServices(IServiceCollection services)
{
Expand All @@ -33,9 +34,9 @@ public void ConfigureServices(IServiceCollection services)
services.AddCsp(nonceByteAmount: 32);
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
public void Configure(IApplicationBuilder app)
{
if (env.IsDevelopment())
if (Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
Expand All @@ -46,16 +47,6 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF
app.UseHsts();
// Manual configuration
//app.UseHsts(new HstsOptions(TimeSpan.FromDays(30), includeSubDomains: false, preload: false));

app.UseHpkp();
// Manual configuration
//app.UseHpkp(hpkp =>
//{
// hpkp.UseMaxAgeSeconds(30 * 24 * 60 * 60)
// .AddSha256Pin("nrmpk4ZI3wbRBmUZIT5aKAgP0LlKHRgfA2Snjzeg9iY=")
// .SetReportOnly()
// .ReportViolationsTo("/hpkp-report");
//});
}

app.UseStaticFiles();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,6 @@
"ForStyles": true
}
},
"Hpkp": {
"ReportOnly": true,
"ReportUri": "/hpkp-report",
"MaxAgeSeconds": 3600,
"Pins": [
"nrmpk4ZI3wbRBmUZIT5aKAgP0LlKHRgfA2Snjzeg9iY="
],
"IncludeSubDomains": false
},
"FeaturePolicy": {
"Camera": {
"AllowSelf": true
Expand Down
2 changes: 1 addition & 1 deletion test/Joonasw.AspNetCore.SecurityHeaders.Samples/web.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" startupTimeLimit="3600" requestTimeout="23:00:00" hostingModel="InProcess">
<environmentVariables>
<environmentVariable name="ASPNETCORE_HTTPS_PORT" value="44342" />
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />
</environmentVariables>
</aspNetCore>
</system.webServer>
Expand Down

0 comments on commit 3812c92

Please sign in to comment.