As the title clarifies why is the auth key introduced in Yii2? What're it's main usages and how it is useful in authentication?
To login a user, you may use the following code: // find a user identity with the specified username. // note that you may want to check the password if needed $identity = User::findOne(['username' => $username]); // logs in the user Yii::$app->user->login($identity);
Authkey is a Cross Channel Communication Platform which allows you to send Notifications using multiple channels at the same time for a certain Event for e.g. Sending Email & Voice for Order details, Voice for COD confirmation etc.
In authentication, the user or computer has to prove its identity to the server or client. Usually, authentication by a server entails the use of a user name and password. Other ways to authenticate can be through cards, retina scans, voice recognition, and fingerprints.
The main use is to authenticate the user by cookie. When you choose to be remembered at Login, this is how you are remembered. The system has to identify and login you somehow. It can either save your username and password in a cookie (that would be unsafe) or it can remember you by other means. This is one of the means. After you login into your Yii application take a look at the _identity cookie that it creates, You will see that the auth_key is part of the cookie.
The cookie actually remembers the $id the $authKey and the $duration, an id\auth_key combination is safer to remember then a username/password one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With