rhurling/nonces

This package is abandoned and no longer maintained. No replacement package was suggested.

Allows the easy use of WordPress-like Nonces in an object-oriented way

3.0.0 2016-03-27 16:36 UTC

This package is auto-updated.

Last update: 2022-05-04 19:03:17 UTC


README

Composer package that replicates WordPress nonces in an object oriented way.

Build Status Coverage Status Scrutinizer Code Quality

Usage

Configure Nonce Defaults

use RouvenHurling\Nonces\Config;

Config::setSalt($salt);
Config::setUserId($userId);
Config::setSessionToken($sessionToken);

Create Nonce

use RouvenHurling\Nonces\Nonce;

$nonce = new Nonce('readme-action');
$nonce->generate();

Verify Nonce

use RouvenHurling\Nonces\Verifer;

$verifier = new Verifier();
$verifier->verify($nonce, $action);

Override global configuration per Nonce

$nonce = new Nonce('Action', $myConfig);
$verifier = new Verifier($myConfig);

$nonce->setLifespan(172800);
$nonce->setAlgorithm('sha256');
$nonce->setSalt($salt);
$nonce->setUserId($userId);
$nonce->setSessionToken($sessionToken);