承接 plopster/jwt-auth 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

plopster/jwt-auth

最新稳定版本:v0.0.1

Composer 安装命令:

composer require plopster/jwt-auth

包简介

Library for standard jwt validation and generation

README 文档

README

A modular and extensible JWT authentication library built on top of firebase/php-jwt.
It provides a clean structure for generating, validating, refreshing, and customizing tokens with support for custom payloads and claim validation.

Installation

composer require yourname/jwt-auth

Usage Example

use JwtAuth\Config\JwtConfig;
use JwtAuth\Claims\DefaultClaimsProvider;
use JwtAuth\Keys\LocalKeyProvider;
use JwtAuth\Services\TokenGenerator;
use JwtAuth\Services\TokenValidator;
use JwtAuth\Services\TokenRefresher;
use JwtAuth\Validation\DefaultClaimValidator;
use JwtAuth\Core\JwtManager;

$config = new JwtConfig(
    issuer: 'my-app',
    audience: 'my-users',
    algorithm: 'RS256',
    privateKeyPath: __DIR__ . '/keys/private.pem',
    publicKeyPath: __DIR__ . '/keys/public.pem',
    ttl: 3600
);

$keyProvider = new LocalKeyProvider($config->privateKeyPath, $config->publicKeyPath);
$claimsProvider = new DefaultClaimsProvider($config->issuer, $config->audience, $config->ttl);
$claimValidator = new DefaultClaimValidator();

$generator = new TokenGenerator($config, $claimsProvider, $keyProvider);
$validator = new TokenValidator($config, $keyProvider);
$refresher = new TokenRefresher($generator);

$jwtManager = new JwtManager($generator, $validator);

// Generate a token
$token = $jwtManager->createToken(['user_id' => 42]);

// Validate the token
$payload = $jwtManager->verifyToken($token);

// Refresh the token
$newToken = $refresher->refresh($payload);

Features

  • Generate JWT tokens with default or custom claims

  • Validate tokens and decode payloads securely

  • Refresh tokens using existing payload data

  • Extend or replace any component:

    • ClaimsProviderInterface for custom payload logic
    • ClaimValidatorInterface for custom validation rules
    • TokenPayloadInterface for custom payload objects
    • KeyProviderInterface for flexible key management (file, env, KMS, etc.)

Project Structure

src/
 ├── Claims/
 ├── Config/
 ├── Contracts/
 ├── Core/
 ├── Exceptions/
 ├── Keys/
 ├── Services/
 └── Validation/

Each folder is modular and follows the single-responsibility principle, making the library scalable and easy to maintain.

License

Proprietary License.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2025-10-25