Coder Social home page Coder Social logo

hpkp's Introduction

HTTP Public Key Pinning (HPKP) middleware

This header has been deprecated citing risks of misuse, and therefore is not recommeded. This module (hpkp) will not receive any new feature development but will still be maintained.

Adds Public Key Pinning headers to Express/Connect applications. To learn more about HPKP, check out the spec, the article on MDN, and this tutorial.

Be very careful when deploying this—you can easily misuse this header and cause problems. Chrome has dropped support for HPKP citing risks of misuse.

Usage:

const express = require("express");
const hpkp = require("hpkp");

const app = express();

const ninetyDaysInSeconds = 7776000;
app.use(
  hpkp({
    maxAge: ninetyDaysInSeconds,
    sha256s: ["AbCdEf123=", "ZyXwVu456="],
    includeSubDomains: true, // optional
    reportUri: "https://example.com", // optional
    reportOnly: false, // optional

    // Set the header based on a condition.
    // This is optional.
    setIf(req, res) {
      return req.secure;
    },
  })
);

Setting reportOnly to true will change the header from Public-Key-Pins to Public-Key-Pins-Report-Only.

Don't let these get out of sync with your certs! It's also recommended to test your HPKP deployment in reportOnly mode, or alternatively, to use a very short maxAge until you're confident your deployment is correct.

hpkp's People

Contributors

dependabot[bot] avatar drewfish avatar evanhahn avatar hatchan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hpkp's Issues

Definitely Typed for TypeScript@next needs a PR for the types-2.0 branch

The upcoming Typescript release will support the new @types/ mechanism, so that .d.ts files can provided via npm install instead of the fragile typings (formerly tsd). For example:

npm install --save-dev @types/helmet

However, @types is using the types-2.0 branch and not the master branch of https://github.com/DefinitelyTyped/DefinitelyTyped:

Unfortunately the PR DefinitelyTyped/DefinitelyTyped#9162 regarding hpkp(...) instead of publicKeyPins(...) is missing in the types-2.0 branch .

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.