Git Product home page Git Product logo

sidio.web.security's Introduction

ASP.NET Core web security

Goal of this project

The goal of this project is to provide a set of services, helper functions and middleware that can be used to secure an ASP.NET Core application. All features are based on the Mozilla Web Security Guidelines.

Packages

Sidio.Web.Security.AspNetCore

Sidio.Web.Security.AspNetCore provides the ASP.NET Core services and middleware. The project targets .NET 8.0 and higher.

build NuGet Version

Sidio.Web.Security.Testing

Sidio.Web.Security.Testing provides testing functionality that can be used to verify that the security headers are set correctly.

build NuGet Version

.NET Framework support: Sidio.Web.Security

Sidio.Web.Security provides the core functionality. Can be used in projects targeting .NET Standard 2.0. It is useful to use this package if .NET Framework is still in use. Otherwise, use Sidio.Web.Security.AspNetCore. Note that this package does not contain the middleware and services that are provided by the ASP.NET Core package. Feel free to make a contribution to this project or a fork targeting .NET Framework.

build NuGet Version

Code quality

Quality Gate Status Coverage

Documentation

See the wiki docs.

Features

HTTP headers

  • Content-Security-Policy: docs
  • Referrer-Policy: docs
  • Report-To: docs
  • Strict-Transport-Security (HSTS): docs
  • X-Content-Type-Options: docs
  • X-Frame-Options: docs

Read more in the wiki docs.

Example

builder.Services
    .AddContentSecurityPolicy();
app.UseXFrameOptions();
app.UseXContentTypeOptions();
app.UseStrictTransportSecurity();
app.UseContentSecurityPolicy(
    (services, b) =>
    {
        b.AddDefaultSrc(x => x.AllowSelf());
        b.AddScriptSrc(x => x.AddNonce(services).AllowUnsafeInline().AllowUrl("https://cdn.example.com"));
        b.AddStyleSrc(x => x.AddNonce(services));
    });

See getting started and the recommended ASP.NET Core configuration.

Reporting API

The reporting API can be used to report violations of the Content Security Policy. Read more in the wiki docs.

Default policies

Testing

The package Sidio.Web.Security.Testing provides a set of functions that can be used to test the security configuration of an ASP.Net Core application. Read more.

Contributions

Contributions are welcome! Feel free to create a pull request or an issue.

License

This project is licensed under the MIT License.

Texts used in this project (including this readme, the code documentation and wiki pages) may come from, or be based on, the MDN Web Doc's. Documentation by Mozilla Contributors is licensed under CC-BY-SA 2.5.

sidio.web.security's People

Contributors

marthijn avatar dependabot[bot] avatar

Stargazers

 avatar Bas van Dijk avatar  avatar

Watchers

 avatar

sidio.web.security's Issues

Subresource integrity

Subresource Integrity (SRI) is a security feature that enables browsers to verify that resources they fetch (for example, from a CDN are delivered without unexpected manipulation.

You use the Subresource Integrity feature by specifying a base64-encoded cryptographic hash of a resource (file) you're telling the browser to fetch, in the value of the integrity attribute of a <script> element or a element with rel="stylesheet", rel="preload", or rel="modulepreload".

Support for: sha256, sha384, and sha512

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.