Skip to content

A php plugin that generates json web tokens for user verification and registers them in a database, together with additional information, for more secure verification.

License

Notifications You must be signed in to change notification settings

Alpus96/jwt_store

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jwt_store

This plugin encodes and decodes JSON web tokens and verifies them by comparing to a database store.

Requiers

PHP version 5.3 (or newer) and a MySQL database, with tables specified in the 'jwt_model.php' file.

Usage

The basic usage requires you to instance the class;

$jwt_store = new TokenStore();


To create a new token do like this;

$id_for_token_in_store = 437;
$obj_to_encode = (object) ['foo' => 'bar'];
$token_string = jwt_store->create($id_for_token_in_store, $obj_to_encode); // String

This will result in a new token string that has been saved in the store and can be verified at a later point.


To verify a token string, and optionaly update it, use the verify function;

$valid = $jwt_store->verify($token_string[, $new_object]); // Boolean

This will result in the token being re-encoded from the previous data, or the new data, if the token string is valid.


To just decode the token, without re-encoding or updating the database, use the decode function;

$data = $jwt_store->decode($token_string); // Object


When the token is no longer valid or in use remove it from the store with the destroy function;

$removed = $jwt_store->destroy($token_string); // Boolean

About

A php plugin that generates json web tokens for user verification and registers them in a database, together with additional information, for more secure verification.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published