aspnetcore security headers
1.0.1
AdamBarclay.AspNetCore.SecurityHeaders nuget 패키지를 설치하십시오.
Install-Package AdamBarclay.AspNetCore.SecurityHeadersASP.NET 파이프 라인에 보안 헤더 미들웨어를 포함하려면 애플리케이션 구성 중에는 다음과 같습니다.
using AdamBarclay . AspNetCore . SecurityHeaders ;그리고 전화 :
app . UseSecurityHeaders ( ) 호출 app.UseSecurityHeaders() 호출에 대한 진동입니다.
app . UseSecurityHeaders (
c =>
{
c . ContentSecurityPolicy ( o =>
{
o . ConfigureDefault ( ) . Self ( ) ;
o . ConfigureObject ( ) . None ( ) ;
o . ConfigureDirective ( "frame-ancestors" ) . None ( ) ;
} ) ;
c . FrameOptions ( o => o . Deny ( ) ) ;
c . ReferrerPolicy ( o => o . StrictOriginWhenCrossOrigin ( ) ) ;
c . StrictTransportSecurity ( o => o . MaxAge ( TimeSpan . FromDays ( 365 ) ) . IncludeSubdomains ( ) ) ;
} ) ; 기본적으로 모든 보안 헤더가 포함되어 있습니다. 헤더를 비활성화하려면 해당 헤더의 구성 빌더에서 Disable() 호출하십시오.
app . UseSecurityHeaders (
c =>
{
c . ContentSecurityPolicy ( o => o . Disable ( ) ) ;
c . ContentTypeOptions ( o => o . Disable ( ) ) ;
c . FrameOptions ( o => o . Disable ( ) ) ;
c . ReferrerPolicy ( o => o . Disable ( ) ) ;
c . StrictTransportSecurity ( o => o . Disable ( ) ) ;
} ) ; content-security-policy 의 기본값은 default-src 'self';frame-ancestors 'none';object-src 'none' 입니다.
x-content-type-options 의 기본값은 nosniff 입니다.
다른 값을 구성 할 수 없습니다.
x-frame-options 의 기본값은 deny 됩니다.
값을 구성하려면 FrameOptions() 구성 빌더를 사용하십시오.
Deny() 호출하여 deny 할 값을 설정하십시오.
app . UseSecurityHeaders ( c => c . FrameOptions ( o => o . Deny ( ) ) ) ; SameOrigin() 에게 전화하여 값을 sameorigin 으로 설정하십시오.
app . UseSecurityHeaders ( c => c . FrameOptions ( o => o . SameOrigin ( ) ) ) ; referrer-policy 의 기본값은 strict-origin-when-cross-origin 입니다.
strict-transport-security 의 기본값은 max-age=31536000;includeSubdomains .