consulate-simple-secrets

simple-secrets token plugin for consulate

consulate-simple-secrets

simple-secrets token plugin for consulate

Just register consulate-simple-secrets as a plugin with your consulate server:

var consulate = require('consulate')
  , ss = require('consulate-simple-secrets');
 
var app = consulate();
 
app.plugin(ss({
  key: '3b6006d164bae955136a5befea9d0e4a50c22a2f7be5d65c2fd67752625deee3'
}));

This will return encrypted tokens with embedded token information:

{
  u: 'user-id',
  s: 42, // compressed scopes 
  c: 'client-id',
  e: 1234 // expiration date 
}

TODO explain how to extract token information

The options accepts a transform function to change the token information. This can be used to add extra fields in the token.

app.plugin(ss({
  transformfunction(clientuserscopeavailableScopestokenOptsdone) {
    // transform the tokenOpts here 
 
    done(null, tokenOpts);
  }
}));
$ npm test