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

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

hao/auth
========

鉴权处理

1.2(4y ago)07MITPHPPHP &gt;=5.6

Since Jun 8Pushed 4y ago1 watchersCompare

[ Source](https://github.com/JZhao1020/auth)[ Packagist](https://packagist.org/packages/hao/auth)[ Docs](https://github.com/JZhao1020/auth)[ RSS](/packages/hao-auth/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

auth
====

[](#auth)

接口鉴权

开源地址
----

[](#开源地址)

\##1.安装

```
composer require hao/auth

```

\##2.实例化

```
$config = [
	// redis配置
    'host'       => '127.0.0.1',
    'port'       => 6379,
    'password'   => '',
    'select'     => 0,
    'timeout'    => 0,
    'expire'     => 0,
    'persistent' => false,
    'prefix'     => '',
    'serialize'  => true,
];
$auth = new \auth\Auth($config);

```

\####redis缓存格式

```
开放平台 - 商户公钥
$key = auth:open_merchant_public_key_xxx （xxx：app_id值）
// 获取公钥内容（仅中间部分）
$public_key = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqW1D7YQPfa2pURezqBbB+Pk9Requx2RP5HV8bl9OBpTMohs5eu/pjCh4UpjlNv75M2v6wuQv6yXUAwYER/jGrFxQVl9rVVegGPHgIbIMTvC8lktIQfe9CURex7vq63oF/GUAWXU+rliE+hg/RcGI53tRRllH7Tt2nB4mKltcpt4OvvaiDeiAZEnBgmgoSpaa3DBazHl1VoBmTvH2jEoo4fH3asQfZbrdf+0IC/zNb0l+QUJTQ7m1M6nvLjXMJGeiqkuAW4szZLLtghUFqqD0uURo5Or9A57Gu7mtNypqRG/7g/qc7/cdrSPzraO2H8RGdU05mg3wsXQCn1rhYiCwXwIDAQAB';
redis()->set($key, $public_key);

商户后台 - token（仅需要校验token的接口）
$key = auth:api_1 (1：用户id)
redis()->set($key, $token);

总后台 - token（仅需要校验token的接口）
$key = auth:admin_1 (1：用户id)
redis()->set($key, $token);

```

\####调用

```
$auth->gateway('api')->check($params);

```

\####返回码

```
code值
200     - 成功
501     - 必填参数异常
505     - 签名失败

```

###  Health Score

22

—

LowBetter than 23% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

Total

3

Last Release

1774d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/150cac62db0286325a8ed8971fb217d79b30f89e3087efd17a0d47863b3a7ab0?d=identicon)[JZhao1020](/maintainers/JZhao1020)

---

Top Contributors

[![JZhao1020](https://avatars.githubusercontent.com/u/22906648?v=4)](https://github.com/JZhao1020 "JZhao1020 (8 commits)")

---

Tags

author

### Embed Badge

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

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M100](/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.2M117](/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)
