function auth(req) { if (!req) { throw new TypeError('argument req is required') } if (typeof req !== 'object') { throw new TypeError('argument req is required to be an object') } // get header var header = getAuthorization(req.req || req) // parse header return parse(header) }
n/a
function auth(req) { if (!req) { throw new TypeError('argument req is required') } if (typeof req !== 'object') { throw new TypeError('argument req is required to be an object') } // get header var header = getAuthorization(req.req || req) // parse header return parse(header) }
n/a
function parse(string) { if (typeof string !== 'string') { return undefined } // parse header var match = CREDENTIALS_REGEXP.exec(string) if (!match) { return undefined } // decode user pass var userPass = USER_PASS_REGEXP.exec(decodeBase64(match[1])) if (!userPass) { return undefined } // return credentials object return new Credentials(userPass[1], userPass[2]) }
...
### auth(req)
Get the basic auth credentials from the given request. The `Authorization`
header is parsed and if the header is invalid, `undefined` is returned,
otherwise an object with `name` and `pass` properties.
### auth.parse(string)
Parse a basic auth authorization header string. This will return an object
with `name` and `pass` properties, or `undefined` if the string is invalid.
## Example
Pass a node request or koa Context object to the module exported. If
...
function auth(req) { if (!req) { throw new TypeError('argument req is required') } if (typeof req !== 'object') { throw new TypeError('argument req is required to be an object') } // get header var header = getAuthorization(req.req || req) // parse header return parse(header) }
n/a
function parse(string) { if (typeof string !== 'string') { return undefined } // parse header var match = CREDENTIALS_REGEXP.exec(string) if (!match) { return undefined } // decode user pass var userPass = USER_PASS_REGEXP.exec(decodeBase64(match[1])) if (!userPass) { return undefined } // return credentials object return new Credentials(userPass[1], userPass[2]) }
...
### auth(req)
Get the basic auth credentials from the given request. The `Authorization`
header is parsed and if the header is invalid, `undefined` is returned,
otherwise an object with `name` and `pass` properties.
### auth.parse(string)
Parse a basic auth authorization header string. This will return an object
with `name` and `pass` properties, or `undefined` if the string is invalid.
## Example
Pass a node request or koa Context object to the module exported. If
...