Skip to content
Myr

Allow colons in passwords for req.auth

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Passwords in basic auth can contain colons (as per RFC2617), while usernames cannot, so assume everything after the colon is a password. This makes req.auth return the correct value if the user uses a colon in his password.

authored by Greg Methvin · committed by Greg Methvin · parent 3ab3021 · Browse files · 2 files+33 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+33 added−2 removed

  • tests:+30 added−0 removed
  • other:+3 added−2 removed

2 files+33 added−2 removed

modified:lib/request.js+3 added-2 removed
391 unmodified lines
392 if (!parts[1]) return;393 auth = parts[1];394395 // credentials396 auth = new Buffer(auth, 'base64').toString().split(':');397 return { username: auth[0], password: auth[1] };396 auth = new Buffer(auth, 'base64').toString().match(/^([^:]*):(.*)$/);397 if (!auth) return;398 return { username: auth[1], password: auth[2] };399});400401/**402 * Return subdomains as an array.
85 unmodified lines
modified:test/req.auth.js+30 added