PHPackages                             kabel-liujun/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. kabel-liujun/auth

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

kabel-liujun/auth
=================

v1.5(3y ago)0177MITPHP

Since Jan 10Pushed 3y ago1 watchersCompare

[ Source](https://github.com/58630540/auth)[ Packagist](https://packagist.org/packages/kabel-liujun/auth)[ RSS](/packages/kabel-liujun-auth/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (2)Versions (22)Used By (0)

### 安装

[](#安装)

1. 下载组件包

    ```
    composer require kabel-liujun/auth
    ```
2. 发布配置文件

    a.kabel\_auth.php: auth配置文件

    b.kabel\_auth\_cache.php: redis缓存链接配置文件

    执行如下命令发布配置文件

    ```
    php artisan vendor:publish --provider="Liujun\Auth\AuthServiceProvide"
    ```

### 授权中间件使用

[](#授权中间件使用)

1.在项目根目录/kabel/Kernel/HttpKernel.php中绑定 \\Liujun\\Auth\\Middleware\\CheckUserToken::class 中间件

```
 /**
     * The application's route middleware.
     *
     * These middleware may be assigned to groups or used individually.
     *
     * @var array
     */
    protected $routeMiddleware = [
        'auth' => \Kabel\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \Kabel\Middleware\RedirectIfAuthenticated::class,
        'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
        'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
        // 绑定用户授权中间件
        'user.token' => \Liujun\Auth\Middleware\CheckUserToken::class,
    ];
```

2.路由绑定中间件

```
    //B端用户系统
    Route::middleware('user.token')->group(function () {
        //需要登录的路由组
    });
   //C端商城小程序用户(cUser)
    Route::middleware('user.token:cUser')->group(function () {
        //需要登录的路由组
    });
   //C端活动小程序用户(aUser)
    Route::middleware('user.token:aUser')->group(function () {
        //需要登录的路由组
    });
```

3.获取当前登录用户的信息 在要使用的文件件 引入

```
   use Liujun\Auth\Traits\UserCacheTrait;
    class test
    {
        /**
        *
        * 引入 serCacheTrait 为B端用户
        * 引入 CUserCacheTraitC端商城小程序用户
        * 引入 AUserCacheTraitCC端活动小程序用户
        */
        use UserCacheTrait;
        public function test()
        {
           $this->_getToken();//获取当前用户的token(所有端通用)
           //以下所有方法都可以传一下bool直参数用来判断是否抛出异常，适合于可登录也不可登录的场景使用
           $this->_getUser();//获取登录用户所有信息(所有端通用)
           $this->_getUserId();//获取用户ID(所有端通用)
           $this->_getUuId();//获取用户UUID（C端专用）
           $this->_getCompany();//获取当前用户所在企业（B端专用）
           $this->_getAppId();//获取当前用户登录的应用ID（B端专用）
           $this->_getProductId();//获取当前用户登录的产品Id（B端专用）
        }
    }
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Recently: every ~2 days

Total

20

Last Release

1451d ago

### Community

Maintainers

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

---

Top Contributors

[![58630540](https://avatars.githubusercontent.com/u/5858351?v=4)](https://github.com/58630540 "58630540 (28 commits)")

### Embed Badge

![Health badge](/badges/kabel-liujun-auth/health.svg)

```
[![Health](https://phpackages.com/badges/kabel-liujun-auth/health.svg)](https://phpackages.com/packages/kabel-liujun-auth)
```

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k272.7M162](/packages/google-auth)[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2509.6M48](/packages/thenetworg-oauth2-azure)[stevenmaguire/oauth2-keycloak

Keycloak OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[robsontenorio/laravel-keycloak-guard

🔑 Simple Keycloak Guard for Laravel

5161.1M3](/packages/robsontenorio-laravel-keycloak-guard)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1132.5M6](/packages/patrickbussmann-oauth2-apple)[wp-graphql/wp-graphql-jwt-authentication

JWT Authentication for WPGraphQL

361118.4k1](/packages/wp-graphql-wp-graphql-jwt-authentication)

PHPackages © 2026

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