Authenticate Yii 2.0 to UserIdentity without a database

Any idea on authentication without using a database ?. I reviewed the basic template. In this application /models/User.php they provided validation based

private static $users = [ '100' => [ 'id' => '100', 'username' => 'admin', 'password' => 'admin', 'authKey' => 'test100key', 'accessToken' => '100-token', ], '101' => [ 'id' => '101', 'username' => 'demo', 'password' => 'demo', 'authKey' => 'test101key', 'accessToken' => '101-token', ], ]; 

But I want the input check to be based on another condition, for example, if a variable satisfies some conditions, it must be logged in. Or any idea on whether I can install Identity Manually?

I referred to http://www.yiiframework.com/doc-2.0/yii-web-identityinterface.html , it also only mentions the use of the database. Do I need to set 'authKey' and 'accessToken' ?

Or can anyone explain the authentication flow in Yii 2.0, what values ​​should be set, in what order?

+7
yii2
source share
1 answer

You can flip your own IdentityInterface and implement it there. But modifying your loginForm.php file in getUser() and validatePassword() methods might work better.

+1
source share

All Articles