Skip to content

Instantly share code, notes, and snippets.

@digitales
Created April 28, 2014 10:36
Show Gist options
  • Save digitales/11368046 to your computer and use it in GitHub Desktop.
Save digitales/11368046 to your computer and use it in GitHub Desktop.
FastCGI authentication header fix
<?php
/**
* Plugin Name: Drew FastCGI authentication
* Description: This works along side the .htaccess to support the PHP_AUTH_PW that are stripped by the PHP FastCGI process
* Author: Ross Tweedie
* Author URI: http://drewlondon.co.uk/
* Version: 0.1
* Plugin URI:
*/
if( isset( $_SERVER['PHP_AUTH_DIGEST_RAW'] ) ){
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) =
explode(':', base64_decode(substr($_SERVER['PHP_AUTH_DIGEST_RAW'], 6)));
}
/**
To go in the .htaccess
<IfModule mod_env.c>
SetEnvIfNoCase ^Authorization$ "(.+)" PHP_AUTH_DIGEST_RAW=$1
</IfModule>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment