viloveul / auth
Viloveul auth with jwt.
v1.0.6
2019-04-18 08:08 UTC
Requires
- php: ~7.0
- lcobucci/jwt: 3.2.*
README
make sure your php version > 7.0
composer require viloveul/auth
HOW
first you need to generate private key and public key
$ openssl genrsa -out private.pem -aes256 4096 $ openssl rsa -pubout -in private.pem -out public.pem
add this
require __DIR__ . '/vendor/autoload.php'; $auth = new Viloveul\Auth\Authentication($your_phrase); $auth->setPrivateKey('private.pem'); $auth->setPublicKey('public.pem'); // create user data $data = new Viloveul\Auth\UserData([ 'id' => 5, 'name' => 'Viloveul', 'email' => 'me@viloveul.com' ]); // get token $token = $auth->generate($data); var_dump($token); // check token $auth->setToken($token); $auth->authenticate(); var_dump($auth->getUser());