Hi,
I'm using the following code in a wiki, which is published behind a firewall. The firewall uses basic http authentication to allow the user access to the site, the user credentials are then passed to the wiki logon which uses LDAP to log the user on.
if(empty($REQUEST['u']) && empty($COOKIE[DOKU_COOKIE])){
if(!empty($SERVER['PHP_AUTH_USER'])){
$REQUEST['u'] = $SERVER['PHP_AUTH_USER'];
$REQUEST['p'] = $SERVER['PHP_AUTH_PW'];
}elseif(!empty($SERVER['HTTP_AUTHORIZATION'])){
list($REQUEST['u'],$REQUEST['p']) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
}
}
All this works great if the user enters the username in the username@domain.com format. However, our users would like to logon using just a username, no domain suffix. So I have changed the LDAP query in the wiki, which works OK, when just logging onto the WIKI internally, as its not behind a firewall, so users just get the wiki logon screen, and can enter their username no password. However, if external users try, the firewall HTTP auth works, but the WIKI logon fails. I believe this is because the firewall is passing the credentials in the DOMAIN.COM\username format, which the WIKI doesn't like. What I'd like to do, is split/explode the following, so the the username variable in the HTTP auth ($_REQUEST['u']) is split at the backslash.
So I need to enter something like:
explode('\',$_REQUEST['u']);
in the following line
list($REQUEST['u'],$REQUEST['p']) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
However, I'm not sure where, I've tried a few different places, but get a number of errors.
Can anyone provide a suggestion?
Many thanks
Ben