This extension is create and validate token.
protected/componentsCREATE TABLE IF NOT EXISTStoken(idint(11) unsigned NOT NULL AUTO_INCREMENT,actionvarchar(100) DEFAULT NULL,identitychar(32) NOT NULL,tokenchar(32) DEFAULT NULL,datatext,expire_timeint(10) unsigned DEFAULT NULL, PRIMARY KEY (id) );
Add componets in main.php
'tokenManager'=>array( 'class'=>'TokenManager', ),
See the following code example: ~~~ * Create token
$token = Yii::app()->tokenManager->create('actionName', array('Some Params'), 172800, array('Data saved in this token'));
$data = Yii::app()->tokenManager->validate('actionName', $token);
Total 2 comments
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 ?
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 login to leave your comment.