token

token base datebase
3 followers

This extension is create and validate token.

Documentation

Requirements

  • Yii 1.0 or above

Installation

  • Extract the release file under protected/components
  • Create table:
    CREATE TABLE IF NOT EXISTS token (
      id int(11) unsigned NOT NULL AUTO_INCREMENT,
      action varchar(100) DEFAULT NULL,
      identity char(32) NOT NULL,
      token char(32) DEFAULT NULL,
      data text,
      expire_time int(10) unsigned DEFAULT NULL,
      PRIMARY KEY (id)
    );
    
  • Add componets in main.php

    'tokenManager'=>array( 'class'=>'TokenManager', ),

Usage

See the following code example: ~~~ * Create token

    $token = Yii::app()->tokenManager->create('actionName', array('Some Params'), 172800, array('Data saved in this token'));
  • Validate token *
    $data = Yii::app()->tokenManager->validate('actionName', $token);
    

Change Log

March 3, 2010

  • Initial release.

March 6, 2010

  • Add public $secretKey and delete SECRET_KEY

Total 2 comments

#761 report it
Rosimildo at 2010/03/03 06:15am
How this compare with a cache

A cache allows you to store "named, value" pairs... and this seems to do the same. What is the difference and when I should use something like this ?

#762 report it
ScallioXTX at 2010/03/03 05:58am
Very nice!

Very nice extension. I was always doing this on a model-by-model basis, where I saved tokens within the model. This of course has the draw back that for every action a new column has to be defined for the tokens. Furthermore, my tokens were not time constrained, these tokens are :)

My one comment is that in the function createTokenKey you refer to the undefined constant SECRET_KEY. I made this $this->secretKey, which is a public variable of the class and defaults to 'secret'. This way this variable can be changed in the config file, so you can give every project another secret key (if you're kinda security paranoid like me :))

Leave a comment

Please to leave your comment.

Create extension