Download the PHP package kakadu-dev/yii2-jwt-auth without Composer
On this page you can find all versions of the php package kakadu-dev/yii2-jwt-auth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-jwt-auth
yii2-jwt-auth
Yii2 JWT Auth
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json
file.
Usage
Once the extension is installed, simply use it in your code by:
Add this package migration namespace, to you console config (console/config/main.php):
Configure api tokens component (e.g. common/config/main.php):
All values in secretKey, issuer, audience, audienceSecrets which contain yii-params.param-name will be converted to Yii::$app->params['param-name']
TBD: add example for yii-params.*
config (e.g. for audienceSecrets
).
Now, after user registration, create JWT tokens and add their in response headers.
Also add an action to update tokens.
E.g.:
or use renew tokens action:
And finally add Jwt Auth to secure controller:
Procedure:
-
seamlessLogin is false
- Register, get access and refresh token and save their on client side.
- Use only access token for request to security endpoint.
- After access token expired, you get 401 Unauthorized exception.
- Use expire access and not expire refresh token to get new tokens. (/refresh-token url)
- If refresh token expire, go to sign in
- seamlessLogin is true
- Register, get access and refresh token and save their on client side.
- Use only access token for request to security endpoint.
- After access token expired, you get 401 Unauthorized exception.
- Repeat request use expire access and not expire refresh token to get new tokens. (/same url)
- If refresh token expire, go to sign in.
That's all. Check it.
All versions of yii2-jwt-auth with dependencies
yiisoft/yii2 Version ~2.0.15
firebase/php-jwt Version ^5.0
ext-json Version *