izzle / token-handler
Simple token handler lib
Installs: 1 301
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- ext-json: *
- ext-pdo: *
- illuminate/encryption: ^10.41
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- phpunit/phpunit: ^9.5
README
Installation
Using composer:
$ composer require izzle/token-handler
Usage
Save Token
use Izzle\TokenHandler\Model\Token; use Illuminate\Encryption\Encrypter; use Izzle\TokenHandler\Handler\FileHandler; // Owner Id for this token. Must be unique. Ex. a User Id. $ownerId = 'someOwnerId'; // Encrypter with random 16 Key for Cipher AES-128-CBC // Cipher AES-256-CBC will need a 32 Char Key $encrypter = new Encrypter('01234567890123456'); $token = (new Token())->setToken('someToken') ->setExpires(time() + 3600) // Ex. expires in 60 Minutes ->setOwnerId($ownerId); $tokenHandler = new FileHandler(sys_get_temp_dir(), $encrypter); $tokenHandler->saveToken($token, $ownerId);
Load Token
use Illuminate\Encryption\Encrypter; use Izzle\TokenHandler\Handler\FileHandler; // Owner Id for this token. Must be unique. Ex. a User Id. $ownerId = 'someOwnerId'; // Encrypter with random 16 Key for Cipher AES-128-CBC // Cipher AES-256-CBC will need a 32 Char Key $encrypter = new Encrypter('01234567890123456'); $tokenHandler = new FileHandler(sys_get_temp_dir(), $encrypter); $token = $tokenHandler->loadToken($ownerId);
License
The Lumen framework is open-sourced software licensed under the MIT license.