-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (31 loc) · 814 Bytes
/
index.js
File metadata and controls
37 lines (31 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var request = require('request')
module.exports = DelegatedAuthentication
function DelegatedAuthentication(config, stuff) {
var self = Object.create(DelegatedAuthentication.prototype)
// config for this module
self._config = config
var url = self._config.url
if (!url) throw new Error('should specify "url" in config')
return self
}
DelegatedAuthentication.prototype.authenticate = function (user, password, cb) {
var self = this
request.get(self._config.url,
{
auth: {
user: user,
password: password,
sendImmediately: true
},
gzip: true,
timeout: 1500
},
function (error, response) {
if (error || response.statusCode != 200) {
return cb(null, false)
} else {
return cb(null, [user])
}
}
)
}