PHPackages                             uicosp/jwt-cas-client - 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. uicosp/jwt-cas-client

ActiveLibrary

uicosp/jwt-cas-client
=====================

The client part for uicosp/jwt-cas-server

1.0.6(9y ago)022MITPHP

Since Dec 29Pushed 9y ago1 watchersCompare

[ Source](https://github.com/uicosp/jwt-cas-client)[ Packagist](https://packagist.org/packages/uicosp/jwt-cas-client)[ RSS](/packages/uicosp-jwt-cas-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

jwt-cas-server
==============

[](#jwt-cas-server)

一个基于 JWT 实现「单点登陆」的 [CAS，Central Authentication System](https://apereo.github.io/cas/4.2.x/planning/Architecture.html) 系统。

本项目依赖于 Laravel。

系统组成
----

[](#系统组成)

- CAS Server （服务端，仅有一个）
- CAS Clients （客户端，多个）

用户只需在 Server 端登陆一次，获得 `token` 后便可用该令牌访问系统中的任意 Clients。

**\[注意\] 此项目为该系统的客户端实现，服务端请移步 **

Client 端提供一个校验 `token` 的中间件

`Uicosp\JwtCasClient\Middleware\VerifyCasToken`

该中间件会验证每次请求中携带的 `token` 的合法性。校验失败将返回错误信息给前端。校验通过则将解密后的 `token` 注入到 `$request` 中。可通过 `$request['verified_token']` 获取。`verified_token` 示例如下：

```
array:6 [
  "sub" => 11
  "iss" => "http://user.dev/jwt/login"
  "iat" => 1482998888
  "exp" => 1483002488
  "nbf" => 1482998888
  "jti" => "e148091d51ece1fb1cf77cc14d317298"
]
```

安装
--

[](#安装)

`composer require "uicosp/jwt-cas-client"`

配置
--

[](#配置)

### 1. 注册服务

[](#1-注册服务)

本项目依赖 [typmon/jwt-auth](https://github.com/tymondesigns/jwt-auth)，请添加

`Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class`, `Uicosp\JwtCasClient\CasServiceProvider::class,`

到 `config/app.php` 的 `providers` 数组。

### 2. 配置秘钥

[](#2-配置秘钥)

#### 方法一，通过环境变量设置

[](#方法一通过环境变量设置)

在 `.env` 文件中设置 `CAS_JWT_SECRET`

#### 方法二，通过 config 文件设置

[](#方法二通过-config-文件设置)

运行命令 `php artisan vendor:publish --provider="Uicosp\JwtCasClient\CasServiceProvider"`, 将在 `config` 目录下新增 `jwt-cas-client.php` 配置文件。

修改

`'jwt_secret' => env('CAS_JWT_SECRET', 'please-change-me'),`

### 3. 添加 Middleware

[](#3-添加-middleware)

将 `Uicosp\JwtCasClient\Middleware\VerifyCasToken::class` 添加到 `app/Http/Kernel.php` 文件中。例如：

```
/**
 * The application's route middleware.
 *
 * These middleware may be assigned to groups or used individually.
 *
 * @var array
 */
protected $routeMiddleware = [
    'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
    'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
    ...
    // 将中间件添加到路由中间件，按需调用
    'auth.cas' => \Uicosp\JwtCasClient\Middleware\VerifyCasToken::class,
];
```

然后在需要的地方调用，例如在 `routes/web.php`：

```
Route::get('/', function () {
    return view('welcome')->middleware('auth.cas');
});
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity67

Established project with proven stability

 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 ~9 days

Total

6

Last Release

3371d ago

### Community

Maintainers

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

---

Top Contributors

[![uicosp](https://avatars.githubusercontent.com/u/14162142?v=4)](https://github.com/uicosp "uicosp (7 commits)")

### Embed Badge

![Health badge](/badges/uicosp-jwt-cas-client/health.svg)

```
[![Health](https://phpackages.com/badges/uicosp-jwt-cas-client/health.svg)](https://phpackages.com/packages/uicosp-jwt-cas-client)
```

###  Alternatives

[jadjoubran/laravel5-angular-material-starter

The Laravel Framework.

1.7k17.2k](/packages/jadjoubran-laravel5-angular-material-starter)[cretueusebiu/laravel-nuxt

A Laravel-Nuxt starter project template.

1.1k6.3k](/packages/cretueusebiu-laravel-nuxt)[hanson/laravel-admin-wechat

2424.4k](/packages/hanson-laravel-admin-wechat)[dreamfactory/df-core

DreamFactory(tm) Core Components

1651.7k20](/packages/dreamfactory-df-core)[rickycezar/laravel-jwt-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

24117.6k](/packages/rickycezar-laravel-jwt-impersonate)[sametsahindogan/laravel-jwtredis

This package allows JWT-authenticated users to be stored and management in Redis with their roles, permissions, statuses and anything you want.

1221.9k](/packages/sametsahindogan-laravel-jwtredis)

PHPackages © 2026

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