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

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

lengbin/auth
============

php auth

071PHP

Since Nov 10Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ice-leng/auth)[ Packagist](https://packagist.org/packages/lengbin/auth)[ RSS](/packages/lengbin-auth/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Auth
====

[](#auth)

感谢yii3

Install
-------

[](#install)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
composer require lengbin/auth

```

or add

```
"lengbin/auth": "*"

```

to the require section of your `composer.json` file.

如果没有看懂可以参考[hyper-helper](https://github.com/ice-leng/hyperf-auth.git)

Usage
-----

[](#usage)

```
// 中间件
class ApiMiddleware extends AbstractAuth implements MiddlewareInterface
{
    /**
     * @inheritDoc
     */
    public function getConfig(): array
    {
        return [
              // 全局变量 名称
              'requestName'   => 'api',
              // 实现类，请实现接口 \Lengbin\Auth\IdentityRepositoryInterface::class
              'identityClass' => User::class,
              // 验证器方法，支持
              // header: \Lengbin\Auth\Method\HttpHeaderAuth::class //默认接收参数名称：X-Api-Token
              // query : \Lengbin\Auth\Method\QueryParamAuth::class //默认接收参数名称：access-token
              // sign  : \Lengbin\Auth\Method\SignAuth::class
              // 如果为 数组 则为 混合验证
              // key => val  接收参数名称 => 验证类
              'method' => [
                  \Lengbin\Auth\Method\HttpHeaderAuth::class,
                  'token' => \Lengbin\Auth\Method\QueryParamAuth::class,
              ],
              //路由白名单。列如 /test/{id}, 可以使用*来通配, /test/*
              'whitelist'     => [],
              //公共访问，不走验证。列如 /test/{id}, 可以使用*来通配, /test/*
              'public'        => [],
          ];
    }

    /**
     * Process an incoming server request.
     *
     * Processes an incoming server request in order to produce a response.
     * If unable to produce the response itself, it may delegate to the provided
     * request handler to do so.
     *
     * @param ServerRequestInterface  $request
     * @param RequestHandlerInterface $handler
     *
     * @return ResponseInterface
     * @throws \Lengbin\Auth\Exception\InvalidTokenException
     */
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $path = $request->getUri()->getPath();
        $isPublic = $this->checkPublicList($path);
        $isWhitelist = $this->checkWhitelist($path);
        $user = $this->getUser($request, $isPublic, $isWhitelist);
        $request->withAttribute($this->requestName, $user);
        return $handler->handle($request);
    }
}
```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9342ed631e7bf15897f2e15d0a853800b84cb315e601eb3a58f2cc8938b5d011?d=identicon)[ice.leng](/maintainers/ice.leng)

---

Top Contributors

[![ice-leng](https://avatars.githubusercontent.com/u/7506787?v=4)](https://github.com/ice-leng "ice-leng (12 commits)")

### Embed Badge

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

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

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

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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