All Projects → damirka → Yii2 Jwt

damirka / Yii2 Jwt

Licence: mit
JWT implementation for Yii2 Authorization process

Projects that are alternatives of or similar to Yii2 Jwt

Yii2 Rabbitmq
RabbitMQ Extension for Yii2
Stars: ✭ 52 (-14.75%)
Mutual labels:  yii2, yii2-extension
Yii2 Gravatar
Gravatar Widget for Yii Framework 2
Stars: ✭ 36 (-40.98%)
Mutual labels:  yii2, yii2-extension
Yii2 Many To Many
Implementation of Many-to-many relationship for Yii 2 framework
Stars: ✭ 30 (-50.82%)
Mutual labels:  yii2, yii2-extension
Config
Yii2 application runtime configuration support
Stars: ✭ 54 (-11.48%)
Mutual labels:  yii2, yii2-extension
Php frameworks analysis
php框架源码分析
Stars: ✭ 57 (-6.56%)
Mutual labels:  yii2, yii2-extension
Yii2 User
[ABANDONED] Flexible user registration and authentication module for Yii2
Stars: ✭ 946 (+1450.82%)
Mutual labels:  yii2, yii2-extension
Yii2 Image Attachment
This extension intended to handle images associated with model.
Stars: ✭ 35 (-42.62%)
Mutual labels:  yii2, yii2-extension
Yii2 C3 Chart
Yii2 wrapper for D3-based reusable chart library
Stars: ✭ 9 (-85.25%)
Mutual labels:  yii2, yii2-extension
Yii2 Lifecycle Behavior
Define the lifecycle of a model by defining allowed status changes.
Stars: ✭ 47 (-22.95%)
Mutual labels:  yii2, yii2-extension
Yii2 Relation Trait
Yii 2 Models add functionality for load with relation, & transactional save with relation PLUS soft delete/restore feature
Stars: ✭ 47 (-22.95%)
Mutual labels:  yii2, yii2-extension
Yii2 Psr Log Target
Yii 2.0 log target that is able to write messages to PSR-3 compatible logger
Stars: ✭ 58 (-4.92%)
Mutual labels:  yii2, yii2-extension
Yii2 Social Share
With this extension you can share data from your web pages to any social network!
Stars: ✭ 48 (-21.31%)
Mutual labels:  yii2, yii2-extension
Yii2 Elfinder
elFinder file manager for Yii 2
Stars: ✭ 21 (-65.57%)
Mutual labels:  yii2, yii2-extension
Sitemap
Site map creation support
Stars: ✭ 59 (-3.28%)
Mutual labels:  yii2, yii2-extension
Yii2 Bx Slider
bx-slider.js wrapper for yii2.
Stars: ✭ 11 (-81.97%)
Mutual labels:  yii2, yii2-extension
Jwt
Kotlin JWT 🔑 implementation (Json Web Token) as required by APNs 🔔 (Apple Push Notifications) or Sign in with Apple 🍏
Stars: ✭ 31 (-49.18%)
Mutual labels:  jwt, json-web-token
Yii2 Telegram Log
Telegram log target for Yii 2
Stars: ✭ 24 (-60.66%)
Mutual labels:  yii2, yii2-extension
Yii2 Slack Log
Pretty Slack log target for Yii 2
Stars: ✭ 24 (-60.66%)
Mutual labels:  yii2, yii2-extension
Yii2 Cms
Simple CMS extension
Stars: ✭ 42 (-31.15%)
Mutual labels:  yii2, yii2-extension
Yii2 Editable
Editable widget and column for gridview.
Stars: ✭ 47 (-22.95%)
Mutual labels:  yii2, yii2-extension

yii2-jwt

JWT implementation for Yii2 Authorization process

For details see JWT official website.

Installation

To install (only master is available now) run:

    composer require "damirka/yii2-jwt:v0.2.1"

Or add this line to require section of composer.json:

    "damirka/yii2-jwt": "v0.2.1"

Usage

There is only one trait - UserTrait - which gives you 5 methods for authorization and JWT-management in User model

Set up:

In controller:

<?php

// ...

use yii\filters\auth\HttpBearerAuth;

class BearerAuthController extends \yii\rest\ActiveController
{
    public function behaviors()
    {
        return array_merge(parent::behaviors(), [
            'bearerAuth' => [
                'class' => HttpBearerAuth::className()
            ]
        ]);
    }
}

In User model:

<?php

// ...

use yii\db\ActiveRecord;
use yii\web\IdentityInterface

class User extends ActiveRecord implements IdentityInterface
{
    // Use the trait in your User model
    use \damirka\JWT\UserTrait;

    // Override this method
    protected static function getSecretKey()
    {
        return 'someSecretKey';
    }

    // And this one if you wish
    protected static function getHeaderToken()
    {
        return [];
    }

    // ...
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].