Whoo
Whoo is a database agnostic authentication library to manage authentication operation easily. Whoo provides you a layer to access and manage user and authentication in your application using Propel ORM.
Installation
composer require abdyek/whoo "1.0.0-beta4"
Notice!
Whoo uses version 2.0 of Propel. Version 2 is not stable version of Propel. So you must hold "minimum-stability":"beta"
in your composer.json until I replace the stable version of Propel instead of the beta version.
Features
- Easy installation, building, usage and learning
- Two-Factor Authentication support
- OAuth2 authentication provider support
- Database agnostic. MySQL, MS SQL Server, PostgreSQL, SQLite, Oracle support (powered by Propel ORM)
- Able to configure for you application
- Portable and standalone
- Destroyable JSON Web Tokens
Getting Started
use Abdyek\Whoo\Controller\SignUp;
use Abdyek\Whoo\Controller\SignIn;
use Abdyek\Whoo\Exception\NotUniqueEmailException;
use Abdyek\Whoo\Exception\IncorrectPasswordException;
use Abdyek\Whoo\Exception\TwoFactorAuthEnabledException;
use Abdyek\Whoo\Exception\InvalidTokenException;
use Abdyek\Whoo\Tool\JWT;
// Whoo once needs to load config
Abdyek\Whoo\Tool\Config::load();
// set secret key of JWT
JWT::setSecretKey('top_secret');
// Sign Up
try {
new SignUp([
'email'=>'[email protected]',
'password'=>'this_is_password'
]);
// successfully registered
} catch(NotUniqueEmailException $e) {
// Oops! the email already is registered
}
// Sign In
try {
$signIn = new SignIn([
'email'=>'[email protected]',
'password'=>'this_is_password'
]);
// You can use $signIn->$jwt you want
} catch(IncorrectPasswordException $e) {
// Wrong password!
} catch(TwoFactorAuthEnabledException $e) {
// You can send authentication code to user via any way you want
// $e->authenticationCode;
}
// JWT Payload
try {
// $jwt is incoming token from the user
$payload = JWT::getPayload($jwt);
$userId = $payload->whoo->userId;
// userId is a unique number for each user in Whoo user model.
// You can use it in your application to expand the user model
} catch(InvalidTokenException $e) {
// Oops!! The token invalid!!
}
Documentation
You can reach all controller class ant other information at wiki page. You can feedback me about documentation.
Versioning
Whoo will have semantic versioning when first stable release.