Skip to content
Permalink
Browse files

using $request->header in place of $_SERVER['HTTP_AUTHORIZATION']

  • Loading branch information...
nicolabeghin committed Mar 15, 2017
1 parent a15c5c7 commit 089a0ae087bf70ac0c2582bb23211eca86da0d93
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/Cake/Controller/Component/Auth/BasicAuthenticate.php
@@ -83,8 +83,8 @@ public function authenticate(CakeRequest $request, CakeResponse $response) {
*/
public function getUser(CakeRequest $request) {
if(!isset($_SERVER['PHP_AUTH_USER'])) {
if (isset($_SERVER['HTTP_AUTHORIZATION']) && strlen($_SERVER['HTTP_AUTHORIZATION']) > 0 && strpos($_SERVER['HTTP_AUTHORIZATION'], 'basic') !== false) {
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
if ($request->header('Authorization') !== false && strlen($request->header('Authorization')) > 0 && strpos($request->header('Authorization'), 'basic') !== false) {
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode(substr($request->header('Authorization'), 6)));
if(strlen($_SERVER['PHP_AUTH_USER']) === 0 || strlen($_SERVER['PHP_AUTH_PW']) === 0) {
unset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
}

0 comments on commit 089a0ae

Please sign in to comment.
You can’t perform that action at this time.