kamoca/laravel-jwt-database-blacklist 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

kamoca/laravel-jwt-database-blacklist

最新稳定版本:v1.0.0

Composer 安装命令:

composer require kamoca/laravel-jwt-database-blacklist

包简介

JWT blacklist storage in database for tymon/jwt-auth

README 文档

README

Latest Version PHP Version License Downloads

A Laravel package to store JWT blacklisted tokens in the database instead of cache.

Built to work with tymondesigns/jwt-auth.

✨ Features

  • 🛡️ Blacklist JWT tokens in a dedicated database table
  • ⚡ Works with tymon/jwt-auth
  • 🗄️ No cache needed
  • ✅ Ready for production use

🚀 Installation

composer require kamoca/laravel-jwt-database-blacklist

⚙️ Setup

  1. Publish migration
php artisan vendor:publish --tag=jwt-blacklist-migrations
php artisan migrate

This will create the jwt_blacklists table in your database.

  1. Configure JWT

    2.1. Set storage

    In config/jwt.php, set the storage option:

    'storage' => Kamoca\JwtDatabaseBlacklist\Providers\Storage\Illuminate::class,

    2.2. Ensure blacklist is enabled

    In config/jwt.php, set the blacklist_enabled option:

    'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true),

    Then in your .env file:

    JWT_BLACKLIST_ENABLED=true

Now, when you invalidate a token, it will be stored in the database and blocked from reuse.

🔧 Usage

Example logout controller:

use Tymon\JWTAuth\Facades\JWTAuth;
use Auth;

public function logout()
{
    // These will store {"valid_until":...} in the `jwt_blacklists` table
    Auth::logout();
    auth()->logout();

    // These will store 'forever' in the `jwt_blacklists` table
    JWTAuth::invalidate(JWTAuth::getToken(), true);
}

Any request using the same token after invalidation will fail.

📝 License

Este projeto está licenciado sob a Licença MIT - veja o arquivo LICENSE para detalhes.

👨‍💻 Author

Kauan Morinel Calheiro

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-02