Skip to content

CrazyAwesomeCompany/api-token

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crazy Awesome API Token

Create and validate API tokens

In this example we create a new token based on the user ID

# ... user is logged in with user id 123
use CAC\Component\Token\Encrypt\McryptToken;
use CAC\Component\Token\TokenGenerator;

$tokenEncrypter = new McryptToken();
$tokenGenerator = new TokenGenerator($tokenEncrypter, 's3cr3tKeY$$');

$token = $tokenGenerator->createToken(123);

Get the user ID back from the token

$userId = $tokenGenerator->validateToken($token);
# $userId = 123

When an invalid token is given the validateToken method returns FALSE

About

Create and validate API tokens

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages