passport-hawk

Passport strategy for the Hawk authentication schema.

Passport.js stategy for the Hawk authentication scheme.

This module allows you to use Hawk as an authentication strategy with passport.

npm install passport-hawk
var HawkStrategy = require('passport-hawk');
 
passport.use('my-hawk-strategy', new HawkStrategy(function (iddone) {
  Users.findById(id, function (erruser){
    if(err) return done(err);
    done(null, {
      key:       user.secret,
      algorithm: 'sha256', // sha1 or sha256 
      user:      user
    });
  });
}));

then you can set my-hawk-strategy as a middlware in any route. For instance:

  myExpressApp.use('/api', 
    passport.authenticate('my-hawk-strategy', { session: false }));

passport-hawk can be used to validate bewit:

var HawkStrategy = require('passport-hawk');
 
passport.use('my-hawk-strategy', new HawkStrategy({ bewit: true }, function (iddone) {
  //..same as previous section 
});

MIT