Skip to content

Commit

Permalink
Update basic-auth.php
Browse files Browse the repository at this point in the history
BasicAuth Header on FPM only available on REDIRECT_HTTP_AUTHORIZATION or HTTP_AUTHORIZATION in my test cases.
  • Loading branch information
thirsch authored Mar 20, 2019
1 parent 9e9d526 commit 624cfda
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions basic-auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ function json_basic_auth_handler( $user ) {
return $user;
}

if (isset($_SERVER['HTTP_AUTHORIZATION'])) {
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':' , base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
} elseif (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':' , base64_decode(substr($_SERVER['REDIRECT_HTTP_AUTHORIZATION'], 6)));
}

// Check that we're trying to authenticate
if ( !isset( $_SERVER['PHP_AUTH_USER'] ) ) {
return $user;
Expand Down

0 comments on commit 624cfda

Please sign in to comment.