Bugfix on Basic Auth username/password split.

Basic Auth uses a colon (":") to separate the username and
password values. Using the php 'explode' function on this
string without limiting the number of substrings returned
can truncate the users password if it contains a colon.
By limiting the explode to 2, we get back the username and
whatever else is left as the password (hence not truncated).
This commit is contained in:
Timothy Brown 2014-12-29 13:04:17 -07:00
parent 39f1d04abe
commit 356c995aa3

View File

@ -106,7 +106,7 @@ class HTTPAuthSession {
if (isset($_SERVER['AUTHORIZATION']) && !empty($_SERVER['AUTHORIZATION'])) {
list ($type, $cred) = explode(" ", $_SERVER['AUTHORIZATION']);
if ($type == 'Basic') {
list ($user, $pass) = explode(":", base64_decode($cred));
list ($user, $pass) = explode(":", base64_decode($cred), 2);
$_SERVER['PHP_AUTH_USER'] = $user;
$_SERVER['PHP_AUTH_PW'] = $pass;
}