Skip to content

Commit

Permalink
Workaround for Basic Auth issue
Browse files Browse the repository at this point in the history
Some CGI/FastCGI implementations don't set the PHP_AUTH_* variables, so potentially set them from a .htaccess environment rule.

See https://github.com/blazersix/satispress/wiki/Basic-Auth and http://stackoverflow.com/questions/3663520/php-auth-user-not-set

See #9.
  • Loading branch information
GaryJones committed May 31, 2016
1 parent 1eb9c25 commit de018f7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions includes/class-satispress-authentication-basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ public function set_base_path( $path ) {
* @since 0.2.0
*/
public function authorize_package_request() {
// Some CGI/FastCGI implementations don't set the PHP_AUTH_* variables, so
// potentially set them from a .htaccess environment rule.
// See https://github.com/blazersix/satispress/wiki/Basic-Auth
if ( ! isset( $_SERVER['PHP_AUTH_USER'] ) && isset( $_SERVER['HTTP_AUTHORIZATION'] ) ) {
list( $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'] ) =
explode( ':', base64_decode( substr( $_SERVER['HTTP_AUTHORIZATION'], 6 ) ) );
}

$user = is_user_logged_in() ? wp_get_current_user() : false;

if ( ! $user && isset( $_SERVER['PHP_AUTH_USER'] ) ) {
Expand Down

0 comments on commit de018f7

Please sign in to comment.