Yii Framework Forum: Yii Password Strategies - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii Password Strategies Rate Topic: ***** 1 Votes

#1 User is offline   phpnode 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 141
  • Joined: 18-April 11

Posted 22 March 2012 - 07:36 AM

Just added this extension:
http://www.yiiframew...ord-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
1

#2 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 261
  • Joined: 15-August 12

Posted 26 March 2013 - 03:34 AM

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

#3 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 26 March 2013 - 01:23 PM

View Postmsoa, on 26 March 2013 - 01:06 PM, said:

I still need help!


So, what?

http://www.catb.org/...-questions.html
"Less noise - more signal"
0

#4 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 261
  • Joined: 15-August 12

Posted 29 March 2013 - 02:03 AM

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?
0

#5 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 261
  • Joined: 15-August 12

Posted 29 March 2013 - 09:32 AM

SOLVED

With changing in line2 of APasswordBehavior.php:
from:
Yii::import("packages.passwordStrategy.*");

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

0

#6 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 261
  • Joined: 15-August 12

Posted 29 March 2013 - 12:55 PM

In here, is there somebody has used this extension?
0

#7 User is offline   kumarkulandai 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 152
  • Joined: 18-November 11
  • Location:Bangalore

Posted 03 April 2013 - 02:12 AM

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?
Regards,
Kumar Kulandai.

Posted Image
0

#8 User is offline   Tushar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 30-July 13

Posted 03 September 2013 - 09:26 AM

View Postkumarkulandai, on 03 April 2013 - 02:12 AM, said:

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/c.../YiiBoilerplate). In there the
Password strategy is inbuilt.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users