0.0.4 • Published 12 years ago

tokenator v0.0.4

Weekly downloads
2
License
-
Repository
github
Last release
12 years ago

Tokenator

Build Status

Tokenator is a lightweight piece of Connect Middleware to provide access control based on a token. It is design to be used with APIs.

Installation

via npm

npm install tokenator

Usage

Tokenator expects the API token to be sent by the client in a header named 'api-token'.

On the server tokenator expects an array of valid tokens.

If a client tries to connect without a token or an invalid token a 401 response will be returned.

For connect

var connect = require('connect')
  , http = require('http')
  , tokenator = require('tokenator');

function accessGranted(req, res){
  res.end('Tokenator says yes!');
}
var app = connect()
  .use(tokenator(['5917f138c80b512d14a4ee2fe05a17dc', '7b1a47ab847f7534b507c6ae4a763118']))
  .use(accessGranted)
 
http.Server(app).listen(3000);

For express

var express = require('express')
  , tokenator = require('tokenator');

var app = module.exports = express.createServer();

app.configure(function(){
  app.use(tokenator(['5917f138c80b512d14a4ee2fe05a17dc', '7b1a47ab847f7534b507c6ae4a763118']))
});

app.get('/', function(req, res){
  res.send('Tokenator says yes!');
});

app.listen(3000);
0.0.4

12 years ago

0.0.3

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago