File tree Expand file tree Collapse file tree 4 files changed +19
-17
lines changed Expand file tree Collapse file tree 4 files changed +19
-17
lines changed Original file line number Diff line number Diff line change 1
1
## ASP.NET Core, Vue.js BFF using Microsoft Entra ID Changelog
2
2
3
+ ### 2024-10-17 0.0.15
4
+ - Updated packages
5
+ - Updated security headers
6
+ -
3
7
### 2024-10-05 0.0.14
4
-
5
8
- Updated packages
6
9
- Updated security headers
7
10
8
11
### 2023-11-17 0.0.3
9
-
10
12
- .NET 8
11
13
12
14
### 2023-09-30 0.0.2
13
-
14
15
- Update packages
15
16
- Fixed dynamic CSP nonce injection
16
17
17
18
### 2023-09-26 0.0.1
18
-
19
19
- Initial version using Vue.js (Typescript & Vite) and ASP.NET Core
20
20
- ASP.NET Core version 7.x
21
21
- Vue.js (typescript & vite)
Original file line number Diff line number Diff line change 8
8
</PropertyGroup >
9
9
10
10
<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 " />
16
16
<PackageReference Include =" NetEscapades.AspNetCore.SecurityHeaders" Version =" 1.0.0-preview.1" />
17
17
<PackageReference Include =" NetEscapades.AspNetCore.SecurityHeaders.TagHelpers" Version =" 1.0.0-preview.1" />
18
18
<PackageReference Include =" Yarp.ReverseProxy" Version =" 2.2.0" />
Original file line number Diff line number Diff line change 16
16
17
17
var services = builder . Services ;
18
18
var configuration = builder . Configuration ;
19
- var env = builder . Environment ;
20
19
21
20
services . AddSecurityHeaderPolicies ( )
22
21
. SetPolicySelector ( ( PolicySelectorContext ctx ) =>
23
22
{
24
- return SecurityHeadersDefinitions . GetHeaderPolicyCollection ( env . IsDevelopment ( ) ,
23
+ return SecurityHeadersDefinitions . GetHeaderPolicyCollection ( builder . Environment . IsDevelopment ( ) ,
25
24
configuration [ "MicrosoftEntraID:Instance" ] ) ;
26
25
} ) ;
27
26
72
71
73
72
IdentityModelEventSource . ShowPII = true ;
74
73
75
- if ( env . IsDevelopment ( ) )
74
+ if ( app . Environment . IsDevelopment ( ) )
76
75
{
77
76
app . UseDeveloperExceptionPage ( ) ;
78
77
app . UseWebAssemblyDebugging ( ) ;
Original file line number Diff line number Diff line change 2
2
3
3
public static class SecurityHeadersDefinitions
4
4
{
5
+ private static HeaderPolicyCollection ? policy ;
6
+
5
7
public static HeaderPolicyCollection GetHeaderPolicyCollection ( bool isDev , string ? idpHost )
6
8
{
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 ;
11
14
12
- var policy = new HeaderPolicyCollection ( )
15
+ policy = new HeaderPolicyCollection ( )
13
16
. AddFrameOptionsDeny ( )
14
17
. AddContentTypeOptionsNoSniff ( )
15
18
. AddReferrerPolicyStrictOriginWhenCrossOrigin ( )
You can’t perform that action at this time.
0 commit comments