Skip to content

Commit ed8ff1f

Browse files
committedMar 24, 2020
clarify auth types
1 parent f5854a6 commit ed8ff1f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed
 

‎lib/http-server.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,8 @@ function HttpServer(options) {
107107
// an attacker knowledge of whether the username is correct via a timing
108108
// attack.
109109
if (credentials) {
110-
// since the `name` and `pass` attributes of `credentials` are always string type
111-
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/HEAD/types/basic-auth/index.d.ts#L15-L16
112-
// so we use `.toString()` to fix https://github.com/http-party/http-server/issues/583
110+
// if credentials is defined, name and pass are guaranteed to be string
111+
// type
113112
var usernameEqual = secureCompare(options.username.toString(), credentials.name);
114113
var passwordEqual = secureCompare(options.password.toString(), credentials.pass);
115114
if (usernameEqual && passwordEqual) {

0 commit comments

Comments
 (0)
Please sign in to comment.