remove Context#auth. Closes #26

This commit is contained in:
TJ Holowaychuk 2013-08-19 18:24:17 -07:00
parent 5f4574b8f5
commit 3d92717b7a
3 changed files with 0 additions and 44 deletions

View file

@ -375,11 +375,6 @@ this.body = yield db.find('something');
of these ips is returned, ordered from upstream -> downstream. When disabled
an empty array is returned.
### ctx.auth
Parses basic auth credentials and returns an object with `.username` and `.password`. It's recommended to use `ctx.secure` to ensure basic auth is only
used over HTTPS.
### ctx.subdomains
Return subdomains as an array.

View file

@ -378,36 +378,6 @@ module.exports = {
: [];
},
/**
* Return basic auth credentials.
*
* Examples:
*
* // http://tobi:hello@example.com
* this.auth
* // => { username: 'tobi', password: 'hello' }
*
* @return {Object} or undefined
* @api public
*/
get auth() {
// missing
var auth = this.get('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().match(/^([^:]*):(.*)$/);
if (!auth) return;
return { username: auth[1], password: auth[2] };
},
/**
* Return subdomains as an array.
*

View file

@ -71,15 +71,6 @@ describe('ctx.header', function(){
})
})
describe('ctx.auth', function(){
it('should parse basic auth', function(){
var ctx = context();
ctx.header.authorization = 'basic Zm9vOmJhcg==';
ctx.auth.username.should.equal('foo');
ctx.auth.password.should.equal('bar');
})
})
describe('ctx.protocol', function(){
describe('when encrypted', function(){
it('should return "https"', function(){