项目作者: uphold

项目描述 :
A middleware to verify HTTP digest headers as described in RFC-3230
高级语言: JavaScript
项目地址: git://github.com/uphold/koa-instance-digest.git
创建时间: 2017-09-14T15:17:25Z
项目社区:https://github.com/uphold/koa-instance-digest

开源协议:MIT License

下载


koa-instance-digest

A middleware to handle verification of HTTP digest headers as described in RFC-3230 “Instance Digests in HTTP”.

Note that, as per the RFC, this module provides:

  • Digest coverage for entire instances communicated via HTTP.
  • Support for multiple digest algorithms.
  • Negotiation of the use of digests.

However, it does NOT provide:

  • header integrity
  • authentication
  • privacy
  • authorization

Status

npm version build status

Installation

Install the package via yarn:

  1. yarn add koa-instance-digest

or via npm:

  1. npm install koa-instance-digest --save

Available algorithms

The following algorithms are available: md5, sha, sha-256, sha-512.

Configuration

The middleware can be configured with the following parameters:

  • algorithms: List of supported algorithms (all by default).
  • required: Whether to set a digest header as mandatory (false by default).

You can change the defaults by doing:

  1. middleware({
  2. algorithms: ['sha-256'],
  3. required: true
  4. });

Usage

  1. const { middleware } = require('koa-instance-digest');
  2. const Koa = require('koa');
  3. const app = new Koa();
  4. app.post('/', middleware(), async ctx => {
  5. // Your code here ...
  6. });
  7. app.listen(3000);

Request

The Digest header can be provided as follows:

  1. 'Digest: <algorithm>=<value>'

Response

If the header is missing the following header will be added to the response:

  1. 'Want-Digest: <list-of-accepted-algorithms>'

Tests

  1. yarn test

Release

  1. npm version [<new version> | major | minor | patch] -m "Release %s"