Sha256: 40b887ddc7cd41812ef841abfaa89dbe1f599cc9f7e725e45cb9f892dd3fda72

Contents?: true

Size: 574 Bytes

Versions: 17

Compression:

Stored size: 574 Bytes

Contents

/**
 * Parse the Authorization header field of `req`.
 *
 * @param {Request} req
 * @return {Object} with .name and .pass
 * @api public
 */

module.exports = function(req){
  req = req.req || req;

  var auth = req.headers.authorization;
  if (!auth) return;

  // malformed
  var parts = auth.split(' ');
  if ('basic' != parts[0].toLowerCase()) return;
  if (!parts[1]) return;
  auth = parts[1];

  // credentials
  auth = new Buffer(auth, 'base64').toString();
  auth = auth.match(/^([^:]*):(.*)$/);
  if (!auth) return;

  return { name: auth[1], pass: auth[2] };
};

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma/node_modules/connect/node_modules/morgan/node_modules/basic-auth/index.js
hooch-0.4.1 jasmine/node_modules/karma/node_modules/connect/node_modules/morgan/node_modules/basic-auth/index.js
hooch-0.4.0 jasmine/node_modules/karma/node_modules/connect/node_modules/morgan/node_modules/basic-auth/index.js
hooch-0.3.0 jasmine/node_modules/karma/node_modules/connect/node_modules/morgan/node_modules/basic-auth/index.js
hooch-0.2.1 jasmine/node_modules/karma/node_modules/connect/node_modules/morgan/node_modules/basic-auth/index.js
hooch-0.2.0 jasmine/node_modules/karma/node_modules/connect/node_modules/morgan/node_modules/basic-auth/index.js
hooch-0.1.0 jasmine/node_modules/karma/node_modules/connect/node_modules/morgan/node_modules/basic-auth/index.js
hooch-0.0.8 jasmine/node_modules/karma/node_modules/connect/node_modules/morgan/node_modules/basic-auth/index.js
hooch-0.0.7 jasmine/node_modules/karma/node_modules/connect/node_modules/morgan/node_modules/basic-auth/index.js
hooch-0.0.6 jasmine/node_modules/karma/node_modules/connect/node_modules/morgan/node_modules/basic-auth/index.js
entangled-0.0.16 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/morgan/node_modules/basic-auth/index.js
entangled-0.0.15 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/morgan/node_modules/basic-auth/index.js
entangled-0.0.14 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/morgan/node_modules/basic-auth/index.js
entangled-0.0.13 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/morgan/node_modules/basic-auth/index.js
entangled-0.0.12 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/morgan/node_modules/basic-auth/index.js
entangled-0.0.11 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/morgan/node_modules/basic-auth/index.js
entangled-0.0.10 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/morgan/node_modules/basic-auth/index.js