Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nicholasbarnaby/5255972 to your computer and use it in GitHub Desktop.
Save nicholasbarnaby/5255972 to your computer and use it in GitHub Desktop.
php kerberos authentication - requires server to have kerberos, apache, php (extends ldap add support for active directory for basic lamp stack)
<?php
if (!isset($_SERVER['PHP_AUTH_USER']) || strcmp($_SERVER['PHP_AUTH_USER'] , "logout" ) == 0 ){
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
$username = $_SERVER['PHP_AUTH_USER'];
echo "{ \"username\": \"" .$username . "\" }";
exit;
} else {
$username = $_SERVER['PHP_AUTH_USER'];
echo "{ \"username\": \"" .$username . "\" }";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment