2017 © Pedro Peláez
 

library token

Coercive Token time based Security

image

coercive/token

Coercive Token time based Security

  • Wednesday, March 21, 2018
  • by Coercive
  • Repository
  • 1 Watchers
  • 1 Stars
  • 814 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 14 % Grown

The README.md

Coercive Token Security

Token allows you to calculate a valid token for the current time and the time before or after. This token is based on the session code, a salt, and time server., (*1)

Get

composer require coercive/token

Usage

<?php
use Coercive\Security\Token\Token;

# REQUIRED : if not, Token throws you an exception
session_start();

# INIT
$Token = new Token(128, 'mySalt0123');

// The first parameter is the length of the random string used in the token
// The second parameter is the custom salt used in the token
// The thirth parameter allow you to specify where the token datas will be store
// The thourth parameter allow you to specify a name for the default global token (if noname)

# CREATE a token
$myKey = $Token->create('example');

# SEND this token with a form (for example)
# and test like this
if( $Token->check( $myKey , 'example' ) ) {
    echo 'Good token !';
    $Token->delete('example');
} else {
    die('Wrong token detected');
}

For form load by AJAX or other complex detection, (*2)

<?php

$Token->check( $myKey , 'example', 'http://www.my-custom-referer');

# OR

$Token->check( $myKey , 'example', [
    'http://www.my-custom-referer-1',
    'http://www.my-custom-referer-2',
    'http://www.my-custom-referer-3'
]);

Get token for others usages, (*3)

<?php

# A basic random string
Token::rand(256);

# A uniq id based on session, salt, random string...
$Token->uniqId();

# A basic (unsafe) token based on datetime
$Token->timer();

# You can use a crypt for customise the timer token
$crypt = 1234567890;
$Token->timer(crypt);


The Versions

21/03 2018

dev-master

9999999-dev http://coercive.fr

Coercive Token time based Security

  Sources   Download

MIT GNU

The Requires

  • php >=7.0

 

21/03 2018

1.1.5

1.1.5.0 http://coercive.fr

Coercive Token time based Security

  Sources   Download

MIT

The Requires

  • php >=7.0

 

07/02 2018

1.1.4

1.1.4.0 http://coercive.fr

Coercive Token time based Security

  Sources   Download

MIT

The Requires

  • php >=7.0

 

28/11 2017

1.1.3

1.1.3.0 http://coercive.fr

Coercive Token time based Security

  Sources   Download

GNU

The Requires

  • php >=7.0

 

01/01 2017

1.1.2

1.1.2.0 http://coercive.fr

Coercive Token time based Security

  Sources   Download

GNU

The Requires

  • php >=7.0

 

19/09 2016

1.1.1

1.1.1.0 http://coercive.fr

Coercive Token time based Security

  Sources   Download

GNU

The Requires

  • php >=7.0

 

13/09 2016

1.1

1.1.0.0 http://coercive.fr

Coercive Token time based Security

  Sources   Download

GNU

The Requires

  • php >=7.0

 

14/07 2016

1.0.0

1.0.0.0 http://coercive.fr

Coercive Token time based Security

  Sources   Download

GNU

The Requires

  • php >=5.4.0