committed by
Kévin Chalet
11 changed files with 129 additions and 45 deletions
@ -0,0 +1,25 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> |
|||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> |
|||
</PropertyGroup> |
|||
|
|||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" /> |
|||
<PropertyGroup Label="Globals"> |
|||
<ProjectGuid>3744b1bc-3498-4958-b020-b2688a78b989</ProjectGuid> |
|||
<RootNamespace>OpenIddict.Security</RootNamespace> |
|||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath> |
|||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup> |
|||
<SchemaVersion>2.0</SchemaVersion> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<DnxInvisibleContent Include="bower.json" /> |
|||
<DnxInvisibleContent Include=".bowerrc" /> |
|||
<DnxInvisibleContent Include="package.json" /> |
|||
</ItemGroup> |
|||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" /> |
|||
</Project> |
|||
@ -0,0 +1,50 @@ |
|||
using System; |
|||
using Microsoft.Extensions.Internal; |
|||
using NWebsec.Middleware; |
|||
|
|||
namespace Microsoft.AspNet.Builder { |
|||
public static class OpenIddictExtensions { |
|||
public static OpenIddictBuilder UseNWebsec([NotNull] this OpenIddictBuilder builder) { |
|||
return builder.UseNWebsec(options => { |
|||
options.DefaultSources(directive => directive.Self()) |
|||
.ImageSources(directive => directive.Self().CustomSources("*")) |
|||
.ScriptSources(directive => directive.Self().UnsafeInline()) |
|||
.StyleSources(directive => directive.Self().UnsafeInline()); |
|||
}); |
|||
} |
|||
|
|||
public static OpenIddictBuilder UseNWebsec( |
|||
[NotNull] this OpenIddictBuilder builder, |
|||
[NotNull] Action<IFluentCspOptions> configuration) { |
|||
return builder.AddModule("NWebsec", -20, app => { |
|||
// Insert a new middleware responsible of setting the Content-Security-Policy header.
|
|||
// See https://nwebsec.codeplex.com/wikipage?title=Configuring%20Content%20Security%20Policy&referringTitle=NWebsec
|
|||
app.UseCsp(configuration); |
|||
|
|||
// Insert a new middleware responsible of setting the X-Content-Type-Options header.
|
|||
// See https://nwebsec.codeplex.com/wikipage?title=Configuring%20security%20headers&referringTitle=NWebsec
|
|||
app.UseXContentTypeOptions(); |
|||
|
|||
// Insert a new middleware responsible of setting the X-Frame-Options header.
|
|||
// See https://nwebsec.codeplex.com/wikipage?title=Configuring%20security%20headers&referringTitle=NWebsec
|
|||
app.UseXfo(options => options.Deny()); |
|||
|
|||
// Insert a new middleware responsible of setting the X-Xss-Protection header.
|
|||
// See https://nwebsec.codeplex.com/wikipage?title=Configuring%20security%20headers&referringTitle=NWebsec
|
|||
app.UseXXssProtection(options => options.EnabledWithBlockMode()); |
|||
}); |
|||
} |
|||
|
|||
public static OpenIddictBuilder UseCors([NotNull] this OpenIddictBuilder builder) { |
|||
//Add CORS to the app
|
|||
builder.AddModule("CORS", -10, map => map.UseCors(options => { |
|||
options.AllowAnyHeader(); |
|||
options.AllowAnyMethod(); |
|||
options.AllowAnyOrigin(); |
|||
options.AllowCredentials(); |
|||
})); |
|||
|
|||
return builder; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
{ |
|||
"version": "1.0.0-*", |
|||
|
|||
"description": "Security headers module for OpenIddict.", |
|||
|
|||
"dependencies": { |
|||
"OpenIddict.Core": "1.0.0-*", |
|||
"NWebsec": { |
|||
"type": "build", |
|||
"version": "1.0.0-internal-*" |
|||
}, |
|||
"Microsoft.Extensions.NotNullAttribute.Sources": { |
|||
"type": "build", |
|||
"version": "1.0.0-*" |
|||
} |
|||
}, |
|||
|
|||
"frameworks": { |
|||
"dnx451": { }, |
|||
"dnxcore50": { } |
|||
} |
|||
} |
|||
Loading…
Reference in new issue