Skip to content

Commit

Permalink
Merge pull request rlidwka#101 from juanpicado/master
Browse files Browse the repository at this point in the history
Fix rlidwka#65 and also PR on fl4re#4
  • Loading branch information
jmwilkinson authored Dec 7, 2016
2 parents 7915bc3 + 32cc6ea commit 014a0b5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: node_js
node_js:
- '0.10'
- '0.12'
- '4'
- '6'
- '7'
- '1'
- '2'
- 'iojs'
Expand Down
2 changes: 1 addition & 1 deletion lib/GUI/entry.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</div>
<div class="col-md-4 col-sm-4">
<div class="author pull-right">
<small>By: {{ _npmUser.name }}</small>
<small>By: {{ author.name }}</small>
</div>
</div>
</div>
Expand Down
12 changes: 6 additions & 6 deletions lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ Auth.prototype.basic_middleware = function() {

var scheme = parts[0]
if (scheme === 'Basic') {
var credentials = Buffer(parts[1], 'base64').toString()
var credentials = new Buffer(parts[1], 'base64').toString()
} else if (scheme === 'Bearer') {
var credentials = self.aes_decrypt(Buffer(parts[1], 'base64')).toString('utf8')
var credentials = self.aes_decrypt(new Buffer(parts[1], 'base64')).toString('utf8')
if (!credentials) return next()
} else {
return next()
Expand Down Expand Up @@ -286,7 +286,7 @@ Auth.prototype.cookie_middleware = function() {
req.remote_user = AuthenticatedUser(user.u, user.g)
req.remote_user.token = token
next()*/
var credentials = self.aes_decrypt(Buffer(token, 'base64')).toString('utf8')
var credentials = self.aes_decrypt(new Buffer(token, 'base64')).toString('utf8')
if (!credentials) return next()

var index = credentials.indexOf(':')
Expand Down Expand Up @@ -314,13 +314,13 @@ Auth.prototype.issue_token = function(user) {
t: ~~(Date.now()/1000),
}, { indent: false })

data = Buffer(data, 'utf8')
data = new Buffer(data, 'utf8')
var mac = Crypto.createHmac('sha256', this.secret).update(data).digest()
return Buffer.concat([ data, mac ]).toString('base64')
}

Auth.prototype.decode_token = function(str, expire_time) {
var buf = Buffer(str, 'base64')
var buf = new Buffer(str, 'base64')
if (buf.length <= 32) throw Error[401]('invalid token')

var data = buf.slice(0, buf.length - 32)
Expand Down Expand Up @@ -355,7 +355,7 @@ Auth.prototype.aes_decrypt = function(buf) {
var b1 = c.update(buf)
var b2 = c.final()
} catch(_) {
return Buffer(0)
return new Buffer(0)
}
return Buffer.concat([ b1, b2 ])
}
Expand Down
2 changes: 1 addition & 1 deletion lib/index-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ module.exports = function(config, auth, storage) {
})

// this is dumb and memory-consuming, but what choices do we have?
stream.end(Buffer(data.data, 'base64'))
stream.end(new Buffer(data.data, 'base64'))
stream.done()
}

Expand Down
2 changes: 1 addition & 1 deletion test/functional/lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Server.prototype.request = function(options) {
}

Server.prototype.auth = function(user, pass) {
this.authstr = 'Basic '+(Buffer(user+':'+pass)).toString('base64')
this.authstr = 'Basic '+(new Buffer(user+':'+pass)).toString('base64')
return this.request({
uri: '/-/user/org.couchdb.user:'+encodeURIComponent(user)+'/-rev/undefined',
method: 'PUT',
Expand Down

0 comments on commit 014a0b5

Please sign in to comment.