File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change
1
+ var timingSafeCompare = require ( 'tsscmp' ) ;
1
2
var http = require ( 'http' ) ;
2
3
3
4
/*!
@@ -53,7 +54,9 @@ module.exports = function basicAuth(callback, realm) {
53
54
if ( 'string' != typeof password ) throw new Error ( 'password argument required' ) ;
54
55
realm = arguments [ 2 ] ;
55
56
callback = function ( user , pass ) {
56
- return user == username && pass == password ;
57
+ const usernameValid = timingSafeCompare ( user , username ) ;
58
+ const passwordValid = timingSafeCompare ( pass , password ) ;
59
+ return usernameValid && passwordValid ;
57
60
}
58
61
}
59
62
Original file line number Diff line number Diff line change 18
18
"url" : " https://github.com/expressjs/basic-auth-connect/issues"
19
19
},
20
20
"devDependencies" : {
21
+ "connect" : " *" ,
21
22
"mocha" : " *" ,
22
23
"should" : " *" ,
23
- "supertest" : " *" ,
24
- "connect" : " *"
24
+ "supertest" : " *"
25
25
},
26
26
"scripts" : {
27
27
"test" : " make test"
28
+ },
29
+ "dependencies" : {
30
+ "tsscmp" : " ^1.0.6"
28
31
}
29
32
}
You can’t perform that action at this time.
0 commit comments