Needlessly Provoking Marsupials

npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

hapi-auth-couchdb

1.0.1 • Public • Published

hapi-auth-couchdb

Lead Maintainer: Aco Mitevski

Supports Hapi 8.0

CouchDB authentication requires validating a AuthSession Cookie. The 'couchdb' scheme takes the following options:

  • validateFunc - (required) a user lookup and password validation function with the signature function(username, password, callback) where:
    • AuthSession - the AuthSession cookie received from the client.
    • callback - a callback function with the signature function(err, isValid, credentials) where:
      • err - an internal error.
      • isValid - true if both the username was found and the password matched, otherwise false.
      • credentials - a credentials object passed back to the application in request.auth.credentials. Typically, credentials are only included when isValid is true, but there are cases when the application needs to know who tried to authenticate even when it fails (e.g. with authentication mode 'try').
 
var validate = function (username, callback) {
 
    var validate = function(authSession, cb) {
        helpers.API.authCheck(authSession)
          .then(function(user) {
            cb(null, true, user);
          }, function(err) {
            cb(err, false, null);
          });
      };
};
 
server.pack.register(require('hapi-auth-couchdb'), function (err) {
 
    server.auth.strategy('simple', 'couchdb', { validateFunc: validate });
    server.route({ method: 'GET', path: '/', config: { auth: 'simple' } });
});

install

npm i hapi-auth-couchdb

Downloadsweekly downloads

10

version

1.0.1

license

MIT

last publish

collaborators

  • avatar
Report a vulnerability