2017 © Pedro Peláez
 

cakephp-plugin cakephp-tokens

CakePHP plugin for generating various (secure) tokens

image

alt3/cakephp-tokens

CakePHP plugin for generating various (secure) tokens

  • Sunday, February 12, 2017
  • by alt3
  • Repository
  • 1 Watchers
  • 2 Stars
  • 54 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 8 % Grown

The README.md

cakephp-tokens

Build Status StyleCI Status Coverage Status Total Downloads License, (*1)

CakePHP plugin for generating various (secure) tokens., (*2)

Abandoned repository, (*3)

Requirements

  • CakePHP 3.+

PHP 5.x users are strongly advised to install the paragonie/random_compat polyfill composer package to ensure generated tokens are truly secure., (*4)

Installation

  1. Install the plugin using composer:, (*5)

    composer require alt3/cakephp-tokens:1.0.x-dev
    
  2. To enable the plugin either run the following command:, (*6)

    bin/cake plugin load Alt3/CakeTokens
    

    or manually add the following line to your config/bootstrap.php file:, (*7)

    Plugin::load('Alt3/CakeTokens');
    
  3. Create the required table used to store the tokens by running:, (*8)

    bin/cake migrations migrate --plugin Alt3/CakeTokens
    

Usage

Inside your controller:, (*9)

use Alt3\Tokens\RandomBytesToken

public function test() {

  // create a token object
  $token = new RandomBytesToken();
  $token->setCategory('password-reset');
  $token->setLifetime('+1 week');

  // save the token object
  $table = TableRegistry::get('Alt3/CakeTokens.Tokens');
  $entity = $table->newEntity($token->toArray());

  if ($table->save($entity)) {
    pr('Successfully saved token with id ' . $entity->id);
  }
}

Visit alt3/tokens for more information about creating the token object and creating your own token-specific Adapters., (*10)

Methods

The TokensTable comes with the following methods:, (*11)

  • setStatus($id, $status): set the status for token with id
  • deleteAllExpired(): deletes all tokens that have expires
  • deleteAllWithStatus($status): deletes all tokens matching given status

Custom Finders

The TokensTable comes with the following custom finders:, (*12)

  • findValidToken: true when given token value (must be passed)exists, has status 0 and has not expired
  • findAllActive: returns all tokens with status 0

Contribute

Before submitting a PR make sure:, (*13)

The Versions

12/02 2017

dev-master

9999999-dev https://github.com/alt3/cakephp-tokens

CakePHP plugin for generating various (secure) tokens

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp tokens alt3