Beispiel #1
0
function login_do_http_auth()
{
    global $LOGIN_PASSWORD, $LOGIN_USERNAME;
    global $_SERVER;
    if ($_SERVER['REMOTE_USER']) {
        is_logged_in(true);
        return;
    }
    if (!$_SERVER['PHP_AUTH_USER']) {
        is_logged_in(false);
        return;
    }
    $status = authenticate($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
    if (!succeeds($status)) {
        is_logged_in(false);
        if (!fatal($status)) {
            if ($_SERVER['PHP_AUTH_USER']) {
                http_401();
            }
        } else {
            print "Error logging in: " . auth_error();
        }
    } else {
        $LOGIN_USERNAME = $_SERVER['PHP_AUTH_USER'];
        $LOGIN_PASSWORD = $_SERVER['PHP_AUTH_PW'];
        is_logged_in(true);
    }
}
Beispiel #2
0
<?php

require_once dirname(__FILE__) . "/../html.php";
require_once dirname(__FILE__) . "/login.php";
require_once dirname(__FILE__) . "/../auth/authentication.php";
if (!defined("LOGIN_SERVICE")) {
    define("LOGIN_SERVICE", 'http');
}
if (isset($PHP_AUTH_USER) and isset($PHP_AUTH_PW)) {
    if (!authenticate($PHP_AUTH_USER, $PHP_AUTH_PW)) {
        http_401();
        print "Access Denied";
        exit;
    } else {
        $LOGIN_USERNAME = $PHP_AUTH_USER;
        $LOGIN_PASSWORD = $PHP_AUTH_PW;
    }
} else {
    http_403();
    Header("WWW-Authenticate: Basic realm='Log In'");
    print "Please Log in";
    exit;
}