Skip to content

switon-php/jwt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Switon JWT Package

JWT encoding, decoding, and key routing for Switon Framework.

Installation

composer require switon/jwt

Requirements: PHP 8.3+

Quick Start

use Switon\Core\Attribute\Autowired;
use Switon\Jwt\JwtInterface;

class AuthService
{
    #[Autowired] protected JwtInterface $jwt;

    public function issue(int $userId): string
    {
        return $this->jwt->encode(['user_id' => $userId], 3600);
    }

    public function authenticate(string $token): array
    {
        return $this->jwt->decode($token);
    }
}

Docs: https://docs.switon.dev/latest/jwt

License

MIT.

About

HMAC JWT issue, validation, and optional kid-based key routing for Switon Framework

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages