コード例 #1
0
ファイル: class.ilAuthHTTP.php プロジェクト: arlendotcn/ilias
 /**
  * Failed login. => Draw login (HTTP 401)
  * @param object $a_username
  * @param object $a_auth
  * @return 
  */
 protected function failedLoginObserver($a_username, $a_auth)
 {
     // First, call parent observer and
     if (!parent::failedLoginObserver($a_username, $a_auth)) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': HTTP authentication failed. Sending status 401');
         $this->drawLogin($a_username);
         return false;
     }
     return false;
 }
コード例 #2
0
<?php

require_once 'config.php';
require_once 'db_login.php';
require_once 'Auth/HTTP.php';
// We use the same connection string as the pear DB functions
$AuthOptions = array('dsn' => "mysql://{$db_username}:{$db_password}@{$db_host}/{$db_database}", 'table' => "users", 'usernamecol' => "username", 'passwordcol' => "password", 'cryptType' => "md5", 'db_fields' => "*");
//echo "<br/>mysql://$db_username:$db_password@$db_host/$db_database\n<br/>";
$authenticate = new Auth_HTTP("DB", $AuthOptions);
$authenticate->setRealm('Member Area');
$authenticate->setCancelText('<h2>Access Denied</h2>');
// request authentication
$authenticate->start();
// compare username and password to stored values
if ($authenticate->getAuth()) {
    if (!isset($_SESSION)) {
        session_start();
    }
    $smarty->assign('blog_title', $blog_title);
    $smarty->display('header.tpl');
    //setup session variable
    $_SESSION['username'] = $authenticate->username;
    $_SESSION['first_name'] = $authenticate->getAuthData('first_name');
    $_SESSION['last_name'] = $authenticate->getAuthData('last_name');
    $_SESSION['user_id'] = $authenticate->getAuthData('user_id');
    echo $_SESSION['username'];
    echo $_SESSION['first_name'];
    echo $_SESSION['last_name'];
    echo $_SESSION['user_id'];
    echo "Login successful. Great to see you ";
    echo $authenticate->getAuthData('first_name');
コード例 #3
0
<?php

require_once "Auth/HTTP.php";
define('DSN', 'sqlite://dummy:@localhost//tmp/user.db?mode=0644');
$options = array('dsn' => DSN);
$auth = new Auth_HTTP("DB", $options);
$auth->setRealm('dummy', 'sample');
$auth->start();
?>
<html>
<head><title>HTTP Basic authentication test for simple case</title></head>
<body>
<?php 
print "auth: " . $auth->authType . "<br />";
print "username: "******"<br />";
print "password: "******"<br />";
print "auth: " . print_r($auth->auth) . "<br />";
if ($auth->getAuth()) {
    print "authentication is succeeded.<br />";
}
?>
</body></html>
コード例 #4
0
ファイル: listing14-7.php プロジェクト: alannet/example
<?php

require_once "Auth/HTTP.php";
// Designate authentication credentials, table name,
// username and password columns, password encryption type,
// and query parameters for retrieving other fields
$dblogin = array('dsn' => "mysqli://*****:*****@localhost/chapter14", 'table' => "logins", 'usernamecol' => "username", 'passwordcol' => "pswd", 'cryptType' => "md5", 'db_fields' => "*");
// Instantiate Auth_HTTP
$auth = new Auth_HTTP("MDB2", $dblogin) or die("Can't connect!");
// Message to provide in case of authentication failure
$auth->setCancelText('Authentication credentials not accepted!');
// Begin the authentication process
$auth->start();
// Check for credentials. If not available, prompt for them
if ($auth->getAuth()) {
    echo "Welcome, {$auth->getAuthData('username')}<br />";
}
?>

コード例 #5
0
ファイル: auth.php プロジェクト: artopantone/anderssehnCMS
<?php

require_once "mysql.php";
require_once "Auth/HTTP.php";
// setting the database connection options
$AuthOptions = array('dsn' => "mysql://{$sql_user}:{$sql_pass}@{$sql_host}/{$sql_data}", 'table' => "auth", 'usernamecol' => "username", 'passwordcol' => "password", 'cryptType' => "none", 'db_fields' => "*");
$auth_http = new Auth_HTTP("DB", $AuthOptions);
$auth_http->setRealm('admin4am');
// realm name
$auth_http->setCancelText('<h2>Error 401 - no login!</h2>');
// error message if authentication fails
$auth_http->start();
// starting the authentication process