lib/app.js
function getAuthorizationData(config, req) {
    let data = null,
      types = Object.keys(config);
    for (let i = 0; i < types.length; i++) {
      let authType = types[i],
        authName = config[authType];
      if (authType === 'header') {
        try {
          let tmp = req.headers[authName] || req.headers[authName.toLowerCase()] || null;
          if (typeof tmp !== 'string' || !tmp) throw 1;
          if (tmp.indexOf('Bearer ') === 0) {
            tmp = tmp.substr(7);
          }
          tmp = tmp.trim();
          if (tmp === '') throw 1;
          data = tmp;
          break;
        } catch (e) {
        }
      }
      if (authType === 'cookie') {
        try {
          let tmp = cookie.parse(req.headers['cookie']);
          if (typeof tmp[authName] !== 'string') throw 1;
          tmp = tmp[authName].trim();
          if (tmp === '') throw 1;
          data = tmp;
          break;
        } catch (e) {
        }
      }
    }
    return data;
  }
function getAuthorizationData(config, req) {
    let data = null,
      types = Object.keys(config);
    for (let i = 0; i < types.length; i++) {
      let authType = types[i],
        authName = config[authType];
      if (authType === 'header') {
        try {
          let tmp = req.headers[authName] || req.headers[authName.toLowerCase()] || null;
          if (typeof tmp !== 'string' || !tmp) throw 1;
          if (tmp.indexOf('Bearer ') === 0) {
            tmp = tmp.substr(7);
          }
          tmp = tmp.trim();
          if (tmp === '') throw 1;
          data = tmp;
          break;
        } catch (e) {
        }
      }
      if (authType === 'cookie') {
        try {
          let tmp = cookie.parse(req.headers['cookie']);
          if (typeof tmp[authName] !== 'string') throw 1;
          tmp = tmp[authName].trim();
          if (tmp === '') throw 1;
          data = tmp;
          break;
        } catch (e) {
        }
      }
    }
    return data;
  }
/*
Returns the authorization information from a request,
based on the configured values.