All Projects → yiisoft → auth-jwt

yiisoft / auth-jwt

Licence: BSD-3-Clause license
www.yiiframework.com/

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to auth-jwt

express-mongo-jwt-boilerplate
Express Mongo JsonWebToken boilerplate
Stars: ✭ 100 (+257.14%)
Mutual labels:  auth, jwt-authentication
auth
www.yiiframework.com/
Stars: ✭ 28 (+0%)
Mutual labels:  auth, yii3
react-google-oauth2.0
React frontend login with OAuth 2.0 & integrates a Rest API backend.
Stars: ✭ 14 (-50%)
Mutual labels:  auth, jwt-authentication
Jwt Auth Guard
JWT Auth Guard for Laravel and Lumen Frameworks.
Stars: ✭ 319 (+1039.29%)
Mutual labels:  auth, jwt-authentication
Auth-using-Vuejs-express-jwt-nodejs
Login and signup form and authentication using Vue.js, express, mongodb, JWT and bootstrap-vue
Stars: ✭ 17 (-39.29%)
Mutual labels:  auth, jwt-authentication
react-auth-kit
Easily manage Authentication state of users in React-based Apps using Hooks and Higher-order components
Stars: ✭ 177 (+532.14%)
Mutual labels:  auth, jwt-authentication
yii-auth-client
Yii Framework external authentication via OAuth and OpenID Extension
Stars: ✭ 20 (-28.57%)
Mutual labels:  auth, yii3
BEW-1.3-Server-Side-Architectures-and-Frameworks
🔐 Build on knowledge of Resourceful and RESTful patterns and dive deep into the Node and Express ecosystem.
Stars: ✭ 19 (-32.14%)
Mutual labels:  jwt-authentication
permissionbolt
🔩 Middleware for keeping track of users, login states and permissions
Stars: ✭ 81 (+189.29%)
Mutual labels:  auth
blueauth
🔐 Serverless passwordless authentication. No databases needed. Use in just 1 line in serverless, middleware, express, next.js, and more.
Stars: ✭ 56 (+100%)
Mutual labels:  auth
TASK-Management-System
Spring Boot and Angular 7 web application for task management .
Stars: ✭ 34 (+21.43%)
Mutual labels:  jwt-authentication
supabase-ui-svelte
Supabase authentication UI for Svelte
Stars: ✭ 83 (+196.43%)
Mutual labels:  auth
package-template
A template for a new package within yiisoft
Stars: ✭ 26 (-7.14%)
Mutual labels:  yii3
littleca
littleca是一个基于BC的小型ca库,支持ecc,rsa,dsa,sm2的证书签发,加密解密,签名验签操作,支持国密加解密,证书签发
Stars: ✭ 44 (+57.14%)
Mutual labels:  auth
dingo-api-demo
dingo+jwt+api
Stars: ✭ 17 (-39.29%)
Mutual labels:  jwt-authentication
casbin-ex
An authorization library that supports access control models like ACL, RBAC, ABAC in Elixir
Stars: ✭ 37 (+32.14%)
Mutual labels:  auth
react-apple-signin-auth
 Apple signin for React using the official Apple JS SDK
Stars: ✭ 58 (+107.14%)
Mutual labels:  auth
JWT-user-auth-API-bolilerplate
Boilerplate for backend API user authentication with JWT
Stars: ✭ 13 (-53.57%)
Mutual labels:  jwt-authentication
Database-Web-API
Dynamically generate RESTful APIs from the contents of a database table. Provides JSON, XML, and HTML. Supports most popular databases
Stars: ✭ 37 (+32.14%)
Mutual labels:  auth
authentication
A framework agnostic authentication library based on PSR standards
Stars: ✭ 19 (-32.14%)
Mutual labels:  jwt-authentication

Yii Auth JWT


Latest Stable Version Total Downloads Build status Scrutinizer Code Quality Code Coverage Mutation testing badge static analysis type-coverage

The package provides JWT authentication method for Yii Auth.

Requirements

  • PHP 7.4 or higher.

Installation

The package could be installed with composer:

composer require yiisoft/auth-jwt --prefer-dist

General usage

Configuring within Yii

  1. Set JWT parameters in your params.php config file:

    'yiisoft/auth-jwt' => [
        'algorithms' => [
            // your signature algorithms
        ],
        'serializers' => [
            // your token serializers
        ],
        'key' => [
            'secret' => 'your-secret',
            'file' => 'your-certificate-file',
        ],
    ],
  2. Setup definitions, required for \Yiisoft\Auth\Middleware\Authentication middleware in a config, for example, in config/web/auth.php:

    <?php
    
    declare(strict_types=1);
    
    /** @var array $params */
    
    use Yiisoft\Auth\Jwt\TokenManagerInterface;
    use Yiisoft\Auth\Jwt\TokenManager;
    use Yiisoft\Auth\AuthenticationMethodInterface;
    use Yiisoft\Auth\Jwt\JwtMethod;
    
    return [
        KeyFactoryInterface::class => [
            'class' => FromSecret::class,
            '__construct()' => [
                $params['yiisoft/auth-jwt']['key']['secret']
            ],
        ],
        
        AuthenticationMethodInterface::class => JwtMethod::class,
    ];

    Note: Don't forget to declare your implementations of \Yiisoft\Auth\IdentityInterface and \Yiisoft\Auth\IdentityRepositoryInterface.

  3. Use Yiisoft\Auth\Middleware\Authentication middleware. Read more about middlewares in the middleware guide.

Configuring independently

You can configure Authentication middleware manually:

/** @var \Yiisoft\Auth\IdentityRepositoryInterface $identityRepository */
$identityRepository = getIdentityRepository();

$tokenRepository = $container->get(\Yiisoft\Auth\Jwt\TokenRepositoryInterface::class);

$authenticationMethod = new \Yiisoft\Auth\Jwt\JwtMethod($identityRepository, $tokenRepository);

$middleware = new \Yiisoft\Auth\Middleware\Authentication(
    $authenticationMethod,
    $responseFactory, // PSR-17 ResponseFactoryInterface.
    $failureHandler // Optional, \Yiisoft\Auth\Handler\AuthenticationFailureHandler by default.
);

Unit testing

The package is tested with PHPUnit. To run tests:

./vendor/bin/phpunit

Mutation testing

The package tests are checked with Infection mutation framework with Infection Static Analysis Plugin. To run it:

./vendor/bin/roave-infection-static-analysis-plugin

Static analysis

The code is statically analyzed with Psalm. To run static analysis:

./vendor/bin/psalm

License

The Yii Auth JWT is free software. It is released under the terms of the BSD License. Please see LICENSE for more information.

Maintained by Yii Software.

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].