aks is an implementation of an Authoritative PGP Key Server, using HAKP, as defined in the HTTP Authoritative Keyserver Protocol.
It is intended to be a demonstration of a working Authoritative Key Server using updated REST principles.
Through NPM
$ npm install aksor using Git
$ git clone git://github.com/treygriffith/aks .git node_modules/aks/aks can be run as a stand-alone web server or as an additional web server inside of a Node application. To create it, simply create an instance of aks and instruct it to listen on the proper port.
It takes as a parameter a database driver that implements the methods described in Key Database Drivers. It ships with a MongoDB driver (on top of Mongoose) as well as a Filesystem driver, meant only for local development use, not as a production server.
var aks = require('aks');
var mongoUrl = 'mongodb://' + db.user + ':' + db.pass + '@' + db.host + ':' + db.port + '/' + db.name;
var mongoKeyDatabase = new aks.drivers.Mongo(mongoUrl, 'keys'); // the storage mechanism for the keys is divorced from serving the keys themselves.
var server = new aks.Server(mongoKeyDatabase);
server.listen(); // defaults to the typical HKP Port of 11371Once the Key Server is listening on a port, it will respond to requests formed in accordance with the Public API.
The optional second parameter when starting the AKS server is an object of options. The possible properties for the options object are:
trustProxy- If set to a truthy value, this tells AKS to trust a proxy which handles SSL connections by respecting theX-Forwarded-Protoheader. See the Express documentation oftrust proxyfor more information. Defaults to false.useIndex- If set to a false-y value, this tells AKS to ignore requests for multiple users, as outlined in Spam Concerns. Defaults to true.baseUri- If set, this should a string, beginning and ending with a forward slash, that defines the base uri at which the key server listens for requests. This is to facillitate the key server co-existing with other services on a single server. Defaults to/.
AKS is implemented such that it is agnostic to how keys are stored/retrieved and interacts with any storage mechanism through a driver that implements the methods required by AKS.
Two database drivers are included with this distribution:
- A filesystem driver intended as a local demonstration of an AKS, and
- A Mongo driver intended as a basic MongodDB interface for an Authoritative Key Server.
Compliant Key Database Drivers implement the following methods:
-
findOne
ThefindOnemethod calls back with a singlekeyobject when supplied with a valid email address as the first parameter. The key object should have at least the following properties defined:keytext- The Public Key Blockuid- The email address which uniquely identifies this keyuser- Portion of the email address prior to the@domain- The domain of the user (portion of the email address after the@)
-
find
The find method should take thedomainas an optional first parameter. If supplied, it should call back with an array of keys corresponding to users of the specifieddomain. Ifdomainis omitted, it should call back with an array of keys for all users on the keyserver. Eachkeyobject in the array should have at least the following properties defined:uid- The email address which uniquely identifies this keyuser- Portion of the email address prior to the@domain- The domain of the user (portion of the email address after the@)
-
add
Theaddmethod should store a key object when supplied with an email address as the first parameter and the Public Key Block as the second parameter. This method is currently not implemented in the Public API, but is necessary for adding additional users to the key server.
A generic driver is included with this distribution as a starting point for future database drivers.