JSON Web Token Authentication for BEAR.Sunday
$ composer require kuma-guy/jwt-auth-module
This package contains two modules for installing JSON Web Token Authentication.
useRay\Di\AbstractModule;
useBEAR\JwtAuth\Auth\Auth;
useBEAR\JwtAuth\SymmetricJwtAuthModule;
class AppModule extends AbstractModule
{
protectedfunctionconfigure()
{
$this->install(newSymmetricJwtAuthModule('symmetric algorithm', 'token time-to-live', 'secret'));
$this->bind(Auth::class)->toProvider(AuthProvider::class)->in(Scope::SINGLETON);
}
}useRay\Di\AbstractModule;
useBEAR\JwtAuth\Auth\Auth;
useBEAR\JwtAuth\AsymmetricJwtAuthModule;
class AppModule extends AbstractModule
{
protectedfunctionconfigure()
{
$this->install(newAsymmetricJwtAuthModule('asymmetric algorithm', 'token time-to-live', 'private key', 'public key', 'pass phrase'));
$this->bind(Auth::class)->toProvider(AuthProvider::class)->in(Scope::SINGLETON);
}
}your user is injected by auth provider, you need to add this line in your resource class
use AuthInject;
