@leisurelink/http-signature
v1.1.1
Published
Reference implementation of Joyent's HTTP Signature scheme.
Downloads
3
Readme
node-http-signature (JWT extension)
A fork of Joyent's HTTP Signature Scheme reference implementation with JWT as an extension.
See Joyent's repository for basic usage and up-to-date information about HTTP Signature.
For reference, you may also peek at HTTP Signature's Internet-Draft status.
Why
HTTP Signature enables the server receiving an HTTP request to trust the identity of the sender as well as the integrity of the message itself without the need for multiple round-trips.
In plain language, this means that the server can trust that the caller is who they say they are (authentic), and that what the server received has not been tampered with in transit (message integrity).
HTTP Signature is:
- synergistic with the REST architectural style
- pure HTTP
- efficient compared to schemes requiring multiple round-trips (e.g. CHAP)
Adding JWT
From the server's point of view, HTTP Signature verifies the identity of a particular network endpoint (the caller) at a particular point in time (at message generation). The confidence this affords the server satisfies many security architectures; however, if the caller makes requests to the server on another security principal's behalf (e.g. an application level user), it is desirable to have the other principal's security related context conveyed with the request. This is where JSON Web Token (JWT) comes in to play.
JSON Web Token encodes a principal's identity claims into a security token that may be trusted across collaborating systems (a federation).
This fork leverages HTTP Signature's built-in extension method to piggy-back a JWT with an HTTP Signature, enabling API endpoints to trust not only the caller (which may be another API endpoint), but also trust an additional security context (the end user).
How
We endeavor to stay entirely drop-in compatible with the forked repository so that libraries that rely on Joyent's module (request
, restify
, etc.) work correctly when this module is overlaid.
As such, this module doesn't create JSON Web Tokens, it simply includes them in the signature if you provide one.
On the server side, Joyent's reference implementation's will place the provided jwt
property on the parsed options: parsed.options.jwt
.
Client
var httpSignature = require('http-signature');
function signWithOptionalJwt(req, jwt, keyId, key) {
var options = {
key: key,
keyId: keyId
};
if (jwt) options.jwt = jwt;
httpSignature.sign(req, options);
return req;
}
Installation
Many node modules already rely on HTTP Signature, so this module is installed by overlaying/patching it in your module's package.json
file.
{
"name": UR-module,
...
"dependencies": {
...
"http-signature": "LeisureLink/node-http-signature",
...
}
}
This module is also published to npm as @leisurelink/http-signature.
License
MIT.
Bugs
See https://github.com/LeisureLink/node-http-signature/issues.