Yii Password Strategies

Just added this extension:

http://www.yiiframework.com/extension/yii-password-strategies/

It deals with hashing and verifying passwords according to specific configurable strategies, so that different types of password hashing methods can be used in the same model. This is useful if you have an existing system that uses e.g. unsalted md5 and you want to upgrade to a more secure system like bcrypt. When users using the legacy md5 passwords log in, their password will automatically be rehashed using the new bcrypt strategy.

More docs and info at github: https://github.com/phpnode/YiiPassword

Post Removed.

reason: mistake question. I found my answer just with carefully reading the code of extension.

So, what?

http://www.catb.org/esr/faqs/smart-questions.html

I extracted files to /protected/YiiPassword and done these steps:

main.php configuration file content:


	

        .

        .

        .

        'import'=>array(

		'application.models.*',

		'application.components.*',

                'application.components.YiiPassword.*',

                'application.helpers.*',

		

	),

        .

        .

        .



And User model:




    .    

    .

    .

    public function behaviors()

    {

        return array(

            "APasswordBehavior" => array(

                "class" => "APasswordBehavior",

                "defaultStrategyName" => "bcrypt",

                "strategies" => array(

                    "bcrypt" => array(

                        "class" => "ABcryptPasswordStrategy",

                        "workFactor" => 14

                    ),

                    "legacy" => array(

                        "class" => "ALegacyMd5PasswordStrategy",

                    )

                ),

            )

        );

    }

    .

    .

    .



and ABcryptPasswordStrategyTest.php:


<?php

Yii::import("application.components.YiiPassword.*");

Yii::import("application.models.*");


/**

 * Tests for the {@link ABcryptPasswordStrategy} class.

 * @author Charles Pick

 * @package packages.passwordStrategy

 */

class ABcryptPasswordStrategyTest extends CTestCase

{

    public function testEncode()

    {

        $strategy = new ABcryptPasswordStrategy();

        $strategy->getSalt(true);

        $password = "qwerty1";

        $this->assertFalse($strategy->compare("test",$strategy->encode($password)));

        $this->assertTrue($strategy->compare("qwerty1",$strategy->encode($password)));


        $user=User::model()->findByAttributes(array('username'=>'user'));

        $strategy = new ABcryptPasswordStrategy();

        $strategy->getSalt(true);

    }

}



Now in Test i get following error:


There was 1 error:


1) ABcryptPasswordStrategyTest::testEncode

CException: Alias "packages.passwordStrategy.*" is invalid. Make sure it points to an existing directory or file.


C:\Apache2\htdocs\yii\framework\YiiBase.php:343

C:\Apache2\htdocs\x\protected\components\YiiPassword\APasswordBehavior.php:2

C:\Apache2\htdocs\yii\framework\YiiBase.php:423

C:\Apache2\htdocs\yii\framework\YiiBase.php:298

C:\Apache2\htdocs\yii\framework\YiiBase.php:198

C:\Apache2\htdocs\yii\framework\base\CComponent.php:327

C:\Apache2\htdocs\yii\framework\base\CComponent.php:298

C:\Apache2\htdocs\yii\framework\db\ar\CActiveRecord.php:389

C:\Apache2\htdocs\x\protected\models\User.php:28

C:\Apache2\htdocs\x\protected\tests\unit\ABcryptPasswordStrategyTest.php:22

C:\php\phpunit:46


FAILURES!

Tests: 1, Assertions: 2, Errors: 1.

What’s problem?

[size="5"]SOLVED[/size]

With changing in line2 of APasswordBehavior.php:

from:


Yii::import("packages.passwordStrategy.*");

to:


Yii::import("application.components.passwordStrategy.*");

In here, is there somebody has used this extension?

I need to use the same password for web application and mobile application which is in encrypted form.

Web app and Mobile app are useing the same database SQL Server.

For Web Application - Yii Framework

For Mobile Applucatin - Apple ios

How to have the same encryption for Yii PHP and Apple iOS?

Download Yii boilerplate (https://github.com/clevertech/YiiBoilerplate). In there the

Password strategy is inbuilt.