Skip to content

Commit 5f17d1a

Browse files
committed
Update packages and security headers
1 parent bd2e760 commit 5f17d1a

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
## ASP.NET Core, Vue.js BFF using Microsoft Entra ID Changelog
22

3+
### 2024-10-17 0.0.15
4+
- Updated packages
5+
- Updated security headers
6+
-
37
### 2024-10-05 0.0.14
4-
58
- Updated packages
69
- Updated security headers
710

811
### 2023-11-17 0.0.3
9-
1012
- .NET 8
1113

1214
### 2023-09-30 0.0.2
13-
1415
- Update packages
1516
- Fixed dynamic CSP nonce injection
1617

1718
### 2023-09-26 0.0.1
18-
1919
- Initial version using Vue.js (Typescript & Vite) and ASP.NET Core
2020
- ASP.NET Core version 7.x
2121
- Vue.js (typescript & vite)

server/BffMicrosoftEntraID.Server.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.8" NoWarn="NU1605" />
12-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.8" />
13-
<PackageReference Include="Microsoft.Identity.Web.GraphServiceClient" Version="3.2.1" />
14-
<PackageReference Include="Microsoft.Identity.Web" Version="3.2.1" />
15-
<PackageReference Include="Microsoft.Identity.Web.UI" Version="3.2.1" />
11+
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.10" NoWarn="NU1605" />
12+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.10" />
13+
<PackageReference Include="Microsoft.Identity.Web.GraphServiceClient" Version="3.2.2" />
14+
<PackageReference Include="Microsoft.Identity.Web" Version="3.2.2" />
15+
<PackageReference Include="Microsoft.Identity.Web.UI" Version="3.2.2" />
1616
<PackageReference Include="NetEscapades.AspNetCore.SecurityHeaders" Version="1.0.0-preview.1" />
1717
<PackageReference Include="NetEscapades.AspNetCore.SecurityHeaders.TagHelpers" Version="1.0.0-preview.1" />
1818
<PackageReference Include="Yarp.ReverseProxy" Version="2.2.0" />

server/Program.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616

1717
var services = builder.Services;
1818
var configuration = builder.Configuration;
19-
var env = builder.Environment;
2019

2120
services.AddSecurityHeaderPolicies()
2221
.SetPolicySelector((PolicySelectorContext ctx) =>
2322
{
24-
return SecurityHeadersDefinitions.GetHeaderPolicyCollection(env.IsDevelopment(),
23+
return SecurityHeadersDefinitions.GetHeaderPolicyCollection(builder.Environment.IsDevelopment(),
2524
configuration["MicrosoftEntraID:Instance"]);
2625
});
2726

@@ -72,7 +71,7 @@
7271

7372
IdentityModelEventSource.ShowPII = true;
7473

75-
if (env.IsDevelopment())
74+
if (app.Environment.IsDevelopment())
7675
{
7776
app.UseDeveloperExceptionPage();
7877
app.UseWebAssemblyDebugging();

server/SecurityHeadersDefinitions.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22

33
public static class SecurityHeadersDefinitions
44
{
5+
private static HeaderPolicyCollection? policy;
6+
57
public static HeaderPolicyCollection GetHeaderPolicyCollection(bool isDev, string? idpHost)
68
{
7-
if (idpHost == null)
8-
{
9-
throw new ArgumentNullException(nameof(idpHost));
10-
}
9+
ArgumentNullException.ThrowIfNull(idpHost);
10+
11+
// Avoid building a new HeaderPolicyCollection on every request for performance reasons.
12+
// Where possible, cache and reuse HeaderPolicyCollection instances.
13+
if (policy != null) return policy;
1114

12-
var policy = new HeaderPolicyCollection()
15+
policy = new HeaderPolicyCollection()
1316
.AddFrameOptionsDeny()
1417
.AddContentTypeOptionsNoSniff()
1518
.AddReferrerPolicyStrictOriginWhenCrossOrigin()

0 commit comments

Comments
 (0)