kuma-guy / jwt-auth-module
JWT authentication module for BEAR.Sunday
1.0.0
2016-09-26 13:49 UTC
Requires
- php: >=7.0.0
- namshi/jose: ^7.1
- ray/aura-web-module: ^0.1.0
- ray/di: ^2.3
Requires (Dev)
- phpmd/phpmd: ~2.3
- phpunit/phpunit: ~4.8 || ~5.0
- squizlabs/php_codesniffer: ~2.3
This package is auto-updated.
Last update: 2024-11-26 17:28:12 UTC
README
JSON Web Token Authentication for BEAR.Sunday
Installation
Composer install
$ composer require kuma-guy/jwt-auth-module
Module install
This package contains two modules for installing JSON Web Token Authentication.
Symmetric way
use Ray\Di\AbstractModule; use BEAR\JwtAuth\Auth\Auth; use BEAR\JwtAuth\SymmetricJwtAuthModule; class AppModule extends AbstractModule { protected function configure() { $this->install(new SymmetricJwtAuthModule('symmetric algorithm', 'token time-to-live', 'secret')); $this->bind(Auth::class)->toProvider(AuthProvider::class)->in(Scope::SINGLETON); } }
Asymmetric way
use Ray\Di\AbstractModule; use BEAR\JwtAuth\Auth\Auth; use BEAR\JwtAuth\AsymmetricJwtAuthModule; class AppModule extends AbstractModule { protected function configure() { $this->install(new AsymmetricJwtAuthModule('asymmetric algorithm', 'token time-to-live', 'private key', 'public key', 'pass phrase')); $this->bind(Auth::class)->toProvider(AuthProvider::class)->in(Scope::SINGLETON); } }
Authentication
your user is injected by auth provider, you need to add this line in your resource class
use AuthInject;