bizley/jwt JWT integration for Yii 2

Latest Stable VersionTotal Downloads LicenseBuild Status

JWT Integration For Yii 2

  1. Installation
  2. Basic usage
  3. JSON Web Tokens

This extension provides the JWT integration for Yii 2 framework.

This is fork of sizeg/yii2-jwt package


Add the package to your composer.json:

    "require": {
        "bizley/jwt": "^2.0"

and run composer update or alternatively run composer require bizley/jwt:^2.0

Basic usage

Add jwt component to your configuration file:

    'components' => [
        'jwt' => [
            'class' => \bizley\jwt\Jwt::class,
            'key' => ... // Secret key string or path to the public key file

Now you have got access to JWT library through Yii::$app->jwt and some helper methods like getBuilder(), getParser(), and getValidationData(). You can validate your JSON Web Token by using validateToken() method and check its signature with verifyToken().

REST authentication

Configure the authenticator behavior in controller.

class ExampleController extends Controller
    public function behaviors()
        $behaviors = parent::behaviors();
        $behaviors['authenticator'] = [
            'class' => \bizley\jwt\JwtHttpBearerAuth::class,

        return $behaviors;

For other configuration options refer to the Yii 2 Guide.

JWT Basic Usage

Please refer to the lcobucci/jwt Documentation.

JSON Web Tokens

2 0
2 293 downloads
Yii Version: 2.0
License: Apache-2.0
Category: Auth
Developed by: Bizley
Created on: Nov 4, 2018
Last updated: (not set)
Packagist Profile
Github Repository

Related Extensions