http-signature

WebJar for http-signature

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

http-signature
Last Version

Last Version

1.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

http-signature
WebJar for http-signature
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

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

Download http-signature

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/http-signature/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>http-signature</artifactId>
    <version>1.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/http-signature/
implementation 'org.webjars.npm:http-signature:1.2.0'
// https://jarcasting.com/artifacts/org.webjars.npm/http-signature/
implementation ("org.webjars.npm:http-signature:1.2.0")
'org.webjars.npm:http-signature:jar:1.2.0'
<dependency org="org.webjars.npm" name="http-signature" rev="1.2.0">
  <artifact name="http-signature" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='http-signature', version='1.2.0')
)
libraryDependencies += "org.webjars.npm" % "http-signature" % "1.2.0"
[org.webjars.npm/http-signature "1.2.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.webjars.npm : assert-plus jar [1.0.0,2)
org.webjars.npm : jsprim jar [1.2.2,2)
org.webjars.npm : sshpk jar [1.7.0,2)

Project Modules

There are no modules declared in this project.

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',
  keyPassphrase: 'secret' // (optional)
});

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.

org.webjars.npm

Joyent

Versions

Version
1.2.0
1.1.1
1.1.0
0.11.0
0.10.1