http-signature
    Overview
    Documentation
    Tutorials
    Chat
    Insights
    Code
    Dependencies
    Contributors
    Jobs

http-signature

Claim

Reference implementation of Joyent's HTTP Signature scheme.

1.2.0  •  Updated 9 months ago  •  by joyent  •  MIT License

node-http-signature

node-http-signature is a node.js library that has client and server components for Joyent’s HTTP Signature Scheme.

Usage

Note the example below signs a request with the same key/cert used to start an HTTP server. This is almost certainly not what you actually want, but is just used to illustrate the API calls; you will need to provide your own key management in addition to this library.

Client

var fs = require('fs');
var https = require('https');
var httpSignature = require('http-signature');

var key = fs.readFileSync('./key.pem', 'ascii');

var options = {
  host: 'localhost',
  port: 8443,
  path: '/',
  method: 'GET',
  headers: {}
};

// Adds a 'Date' header in, signs it, and adds the
// 'Authorization' header in.
var req = https.request(options, function(res) {
  console.log(res.statusCode);
});


httpSignature.sign(req, {
  key: key,
  keyId: './cert.pem'
});

req.end();

Server

var fs = require('fs');
var https = require('https');
var httpSignature = require('http-signature');

var options = {
  key: fs.readFileSync('./key.pem'),
  cert: fs.readFileSync('./cert.pem')
};

https.createServer(options, function (req, res) {
  var rc = 200;
  var parsed = httpSignature.parseRequest(req);
  var pub = fs.readFileSync(parsed.keyId, 'ascii');
  if (!httpSignature.verifySignature(parsed, pub))
    rc = 401;

  res.writeHead(rc);
  res.end();
}).listen(8443);

Installation

npm install http-signature

License

MIT.

Bugs

See https://github.com/joyent/node-http-signature/issues.

Popularity

Maintenance

Development

Last ver 3 years ago
Created 9 years ago
Last commit 1 month ago
1 month between commits

Technology

Node version: 0.12.9
0 unpacked

Compliance

MIT License
OSI Approved
0 vulnerabilities

Contributors

28 contributors
Mark Cavage
18 commits, 13 merges
Alex Wilson
21 commits, 2 PRs
David I. Lehn
15 commits, 4 PRs
Works at Digital Bazaar, Inc.
Mark Cavage
12 commits
Jason King
4 commits, 7 merges, 4 PRs
Trent Mick
4 commits, 4 merges, 3 PRs
Works at Joyent

Tags

https
request
Openbase helps developers choose among and use millions of open-source packages, so they can build amazing products faster.
FacebookTwitterLinkedIn
© 2020 Devstore, Inc.