开发者

What options are available to secure a Drupal site via HTTP authentication?

How can I implement HTTP authentication for a Drupal based web app in or开发者_如何学编程der to restrict access, e.g. for developers only?


We enable .htpasswd to present a login prompt.

You can also use this if you want a module:

http://drupal.org/project/securesite


$LoginSuccessful = false;
if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])){
    $Username = $_SERVER['PHP_AUTH_USER'];
    $Password = $_SERVER['PHP_AUTH_PW'];
    if ($Username == 'username_test' && $Password == 'password_test'){
        $LoginSuccessful = true;
    }
}

// Login passed successful?
if (!$LoginSuccessful){
    header('WWW-Authenticate: Basic realm="Secret page"');
    header('HTTP/1.0 401 Unauthorized');
    print "Login failed!\n";
    exit();
}

Solved my issue.. thnks...


If Apache's htaccess is enough for you, read here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜