3 * Parse the Authorization header field of `req`.
6 * @return {Object} with .name and .pass
10 module.exports = function(req){
13 var auth = req.headers.authorization;
17 var parts = auth.split(' ');
18 if ('basic' != parts[0].toLowerCase()) return;
19 if (!parts[1]) return;
23 auth = new Buffer(auth, 'base64').toString();
24 auth = auth.match(/^([^:]*):(.*)$/);
27 return { name: auth[1], pass: auth[2] };