PHPackages                             red-jasmine/jwt-auth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. red-jasmine/jwt-auth

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

red-jasmine/jwt-auth
====================

JWT Authentication package for Red Jasmine Framework

1.0.13(5mo ago)0431MITPHP

Since Jan 20Pushed 5mo agoCompare

[ Source](https://github.com/red-jasmine/jwt-auth)[ Packagist](https://packagist.org/packages/red-jasmine/jwt-auth)[ Docs](https://github.com/red-jasmine/jwt-auth)[ RSS](/packages/red-jasmine-jwt-auth/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (10)Used By (1)

Red Jasmine JWT Auth
====================

[](#red-jasmine-jwt-auth)

JWT认证包，为Red Jasmine框架提供灵活的JWT认证功能。

特性
--

[](#特性)

- 自定义UserProvider，支持从token直接解析用户信息
- 支持多模型配置，可根据不同用户类型使用不同的模型
- 无需数据库查询即可从token中获取用户信息
- 兼容Laravel认证系统

安装
--

[](#安装)

```
composer require red-jasmine/jwt-auth
```

配置
--

[](#配置)

### 1. 发布配置文件

[](#1-发布配置文件)

```
php artisan vendor:publish --provider="RedJasmine\JwtAuth\JwtAuthServiceProvider" --tag="config"
```

### 2. 配置认证提供者

[](#2-配置认证提供者)

在 `config/auth.php` 中添加JWT提供者配置：

```
'providers' => [
    'jwt' => [
        'driver' => 'jwt',
        'models' => [
            'user' => \App\Models\User::class,
            'admin' => \App\Models\Admin::class,
            // 更多类型...
        ],
    ],
],
```

### 3. 配置守卫

[](#3-配置守卫)

```
'guards' => [
    'api' => [
        'driver' => 'jwt',
        'provider' => 'jwt',
    ],
],
```

使用
--

[](#使用)

### 生成Token

[](#生成token)

```
use Illuminate\Support\Facades\Auth;

// 登录用户
$user = User::find(1);
$token = Auth::guard('api')->login($user);
```

### 验证Token

[](#验证token)

```
use Illuminate\Support\Facades\Auth;

// 从请求头中获取token
$user = Auth::guard('api')->user();
```

### 多模型支持

[](#多模型支持)

```
// 为用户类型生成token
$token = Auth::guard('api')->login($user, 'user');

// 为管理员类型生成token
$token = Auth::guard('api')->login($admin, 'admin');
```

架构
--

[](#架构)

本包采用以下架构设计：

- **JwtUserProvider**: 自定义用户提供者，实现从token解析用户信息
- **JwtGuard**: JWT守卫，处理token验证和用户认证
- **JwtAuthServiceProvider**: 服务提供者，注册认证驱动和配置

许可证
---

[](#许可证)

MIT License

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance72

Regular maintenance activity

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

8

Last Release

165d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/aaaa10537dd96827181cb5ff0c4df6078f48054457d9ebaebe0b230829482843?d=identicon)[liushoukun](/maintainers/liushoukun)

---

Top Contributors

[![liushoukun](https://avatars.githubusercontent.com/u/26298472?v=4)](https://github.com/liushoukun "liushoukun (2 commits)")

---

Tags

jwtlaravelAuthenticationred-jasmine

### Embed Badge

![Health badge](/badges/red-jasmine-jwt-auth/health.svg)

```
[![Health](https://phpackages.com/badges/red-jasmine-jwt-auth/health.svg)](https://phpackages.com/packages/red-jasmine-jwt-auth)
```

###  Alternatives

[auth0/login

Auth0 Laravel SDK. Straight-forward and tested methods for implementing authentication, and accessing Auth0's Management API endpoints.

2795.3M3](/packages/auth0-login)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
