1. Go to this page and download the library: Download popphp/pop-auth library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
popphp / pop-auth example snippets
use Pop\Auth;
$auth = new Auth\File('/path/to/.htmyauth');
if ($auth->authenticate('admin', 'password')) {
// User is authenticated
} else {
// Handle failed authentication attempt
}
var_dump($auth->isAuthenticated()); // bool
use Pop\Auth;
$auth = new Auth\File('/path/to/.htmyauth');
$auth->authenticate('testuser1', 'password'); // Return int
if ($auth->isAuthenticated()) { } // Returns bool
use Pop\Auth;
$auth = new Auth\Table('MyApp\Table\Users');
$auth->authenticate('admin', 'password'); // int
if ($auth->isAuthenticated()) { } // bool
use Pop\Auth;
$auth = new Auth\Table('MyApp\Table\Users');
$auth->setUsernameField('user_name')
->setPasswordField('password_hash');
$auth->authenticate('admin', 'password'); // int
if ($auth->isAuthenticated()) { } // bool
use Pop\Auth\Http;
use Pop\Http\Client;
$auth = new Http(new Client('https://www.domain.com/auth', ['method' => 'post']));
$auth->authenticate('admin', 'password'); // Returns int
if ($auth->isAuthenticated()) { } // Returns bool
use Pop\Auth\Http;
use Pop\Http\Client;
use Pop\Http\Auth;
$client = new Client(
'https://www.domain.com/auth', ['method' => 'post'],
Auth::createBasic('admin', 'password')
);
$auth = new Http($client);
$auth->authenticate('admin', 'password'); // Returns int
if ($auth->isAuthenticated()) { } // Returns bool
use Pop\Auth\Http;
use Pop\Http\Client;
use Pop\Http\Auth;
$client = new Client(
'https://www.domain.com/auth', ['method' => 'post'],
Auth::createBearer('AUTH_TOKEN')
);
$auth = new Http($client);
$auth->authenticate('admin', 'password');
if ($auth->isAuthenticated()) { } // Returns true
use Pop\Auth\Http;
use Pop\Http\Client;
$auth = new Http(new Client('https://www.domain.com/auth', ['method' => 'post']));
$auth->setUsernameField('user_name')
->setPasswordField('password_hash');
$auth->authenticate('admin', 'password'); // Returns int
if ($auth->isAuthenticated()) { } // Returns bool
use Pop\Auth;
$auth = new Auth\Ldap('ldap.domain', 389, [LDAP_OPT_PROTOCOL_VERSION => 3]);
$auth->authenticate('admin', 'password');
if ($auth->isAuthenticated()) { } // Returns true
use Pop\Auth;
$auth = new Auth\Table('MyApp\Table\Users');
$auth->authenticate('admin', 'password'); // int
if ($auth->isAuthenticated()) {
$user = $auth->getUser();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.