0.2.0 • Published 9 years ago

express-authentication-verify v0.2.0

Weekly downloads
14
License
CC0-1.0
Repository
github
Last release
9 years ago

express-authentication-verify

Authentication callbacks for express-authentication middleware builders.

build status coverage license version downloads

You're an implementor of authentication middleware and you want to provide your users with a callback mechanism to assign the relevant authentication properties? Fear no more!

var verifier = require('express-authentication-verify');

module.exports = function(options) {
	// Create verify middleware.
	var verify = verifier(options);

	// Return your middleware!
	return function(req, res, next) {

		// Extract the authentication challenge from the client first
		// If no challenge is provided, the user's callback will never be
		// executed.
		req.challenge = ...;

		// Invoke the users verification callback in order to set the relevant
		// express-authentication properties on the request.
		verify(req, res, function(err) {
			if (err) {
				return next(err);
			}
			// req.authenticated / req.authentication are now set
			// do any post-flight you want here
			next();
		});
	}
}

The result returned is middleware just like anything else.