Identify

Identify is a complete authentication system with session management and cryptographic libraries. It including many third-party library.

Session

The RedCat's session handler is independent from native php session and use a strong random id cookie which is regenerated when $cookieLifetime expire. Unlike native php session it allow you to use a session over any length you want, like one year for example, and it integrate an anti-bruteforce system with attempts records based on hashed ip. $name = 'redcat';
$cookieLifetime = 3600; // 1 hour
$sessionLifetime = 43200;  // 1 year
$session = new \RedCat\Identify\Session($name,$cookieLifetime,$sessionLifetime);
if(isset($session['var']))
    var_dump( $session['var'] );
$session['var'] = 'value';
            

Auth

Here is the main authentication API which you can use with Auth class.

login

$auth->login($login, $password, $lifetime=0);
            

loginRoot

$auth->loginRoot($password,$lifetime=0);
            

loginPersona

$auth->loginPersona($email,$lifetime=0);
            

register

$auth->register($email, $login, $password, $repeatpassword, $name=null);
            

activate

$auth->activate($key);
            

requestReset

$auth->requestReset($email);
            

logout

$auth->logout();
            

getHash

$auth->getHash($string, $salt);
            

getUID

$auth->getUID($login);
            

getUser

$auth->getUser($uid);
            

deleteUser

$auth->deleteUser($uid, $password);
            

validateLogin

$auth->validateLogin($login);
            

validateDisplayname

$auth->validateDisplayname($login);
            

resetPass

$auth->resetPass($key, $password, $repeatpassword);
            

resendActivation

$auth->resendActivation($email);
            

changePassword

$auth->changePassword($uid, $currpass, $newpass, $repeatnewpass);
            

getEmail

$auth->getEmail($uid);
            

changeEmail

$auth->changeEmail($uid, $email, $password);
            

getRight

$auth->getRight();
            

setRight

$auth->setRight($r);
            

connected

$auth->connected();
            

allowed

$auth->allowed($d);
            

allow

$auth->allow($d);
            

deny

$auth->deny($d);
            

lock

$auth->lock($r,$redirect=true);
            

AuthServer

First parameter correspond to RedCat\Identify\Auth rights constants. You can use them directly, or if you use string (like in example) it will be automaticaly converted to corresponding constant. The rights constants are Auth::RIGHT_MANAGE, Auth::RIGHT_EDIT, Auth::RIGHT_MODERATE, Auth::RIGHT_POST.
The second parameter (true by default) is for enable GET redirection to avoid re-POST on refresh. $authServer = new \RedCat\Identify\AuthServer;
$authServer->htmlLock('RIGHT_MANAGE',true);
            
Following example is for use inside a code (off course with ob-implicit-flush setted to false). It will handle authentication process, from locking with authentication window to logout button ouput. Put the code where you want button to appear. $authServer->lougoutBTN();
            
For handle signup and login process: $authServer->action();
            
For get identity: $session = $authServer->getSession();
$identity = $session['_AUTH_'];
            
For handle reset password request: $authServer->resetreq();
            
For handle reset password confirmation: $authServer->resetpass();
            
For logout: $authServer->getAuth()->logout()
            
And, in any context, to get result message: echo $authServer->getResultMessage(true);
            

PHPMailer

PHPMailer - A full-featured email creation and transfer class for PHP.
PHPMailer is a third party toolbox. See the official PHPMailer and examples. There is simple facade class in RedCat\Identify namespace for use PHPMailer in simplicity:
$mailer = new RedCat\Identify\PHPMailer(
    $fromEmail,$fromName,
    $replyEmail,$replyName,
    $host,$port,$username,$passowrd,$secure,
    $sendmail,
    $debug,$exceptions
);
$mailer->mail($email, $subject, $message, $html=true);
            

RandomLib

RandomLib - A library for generating random numbers and strings.
RandomLib is a third party toolbox. See the official RandomLib

SecurityLib

SecurityLib is a third party toolbox (dependency of RandomLib). See the official SecurityLib

PhpSecLib

PhpSecLib - PHP Secure Communications Library.
PhpSecLib is a third party cryptography toolbox. See the official PhpSecLib

tags: