PHPackages                             matheus-carmo/auth-3 - 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. matheus-carmo/auth-3

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

matheus-carmo/auth-3
====================

The Hyperf Auth package.

01PHP

Since Sep 30Pushed 2y agoCompare

[ Source](https://github.com/MatheusFelipeMarinho/auth-3)[ Packagist](https://packagist.org/packages/matheus-carmo/auth-3)[ RSS](/packages/matheus-carmo-auth-3/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Hyperf 认证组件
===========

[](#hyperf-认证组件)

This repo adjust compatibility with new version by Hyperf
=========================================================

[](#this-repo-adjust-compatibility-with-new-version-by-hyperf)

该组件移植了 Laravel Auth 组件（[illuminate/auth](https://github.com/illuminate/auth)）相对完整的功能特性，除了中间件传参和邮件通知。

- Hyperf 的中间件遵循 PSR-15 的规范，无法使用 Laravel 的方式通过路由向中间件传递值，故在实现上与 Laravel 不同，仅实现了一个基础的身份认证中间件抽象类 `HyperfExt\Auth\Middlewares\AbstractAuthenticateMiddleware`。
- 邮件（[illuminate/mail](https://github.com/illuminate/mail)）和通知（[illuminate/notifications](https://github.com/illuminate/notifications)）尚未移植完成。

该组件实现了两个自定义注解。

- Hyperf\\Di\\Annotations\\AbstractAnnotation\\Auth
    可用于类和方法，语法 `Auth({"GUARD_CONF_NAME"[, ...]}[, passable=bool])`：

    - 第一个参数为 Guard 名列表
    - 第二个 `passable` 可选参数默认值为 `false`，设置为 `true` 时未认证的用户也可以通过 Guard，不会抛出为认证的异常，在某些特殊情况下将会比较有用。例如，同一个 API 需要对认证用户和非认证用户展示不同的数据。
- Hyperf\\Di\\Annotations\\AbstractAnnotation\\Policy
    可用于类，语法 `Policy({"MODEL_FQCN"\[, ...\]})`：

    - 参数为模型 FQCN 列表

另外，Gate 和策略的注册方法与 Laravel 不同。

Gate 可以通过注入 `HyperfExt\Auth\Contracts\Access\GateManagerInterface` 来调用实例的 `define` 方法注册。或者监听 `HyperfExt\Auth\Events\GateManagerResolved` 事件来在监听器中访问事件的 `gate` 属性（GateManagerInterface）来注册。

策略可以通过 `gen:policy` 命令来创建，例如 `gen:policy PostPolicy --model=App\\Model\\Post`。也可以在配置文件的 `policies` 中定义模型类和策略类的映射。

如需使用 JWT，请额外安装 [`hyperf-ext/jwt`](https://github.com/hyperf-ext/jwt) 组件。

安装
--

[](#安装)

```
composer require matheus-carmo/auth-3
```

发布配置
----

[](#发布配置)

```
php bin/hyperf.php vendor:publish hyperf-ext/auth
```

> 文件位于 `config/autoload/auth.php`。

配置
--

[](#配置)

> 详细说明见配置文件。

使用
--

[](#使用)

### 身份认证

[](#身份认证)

文档待完成。

### 授权

[](#授权)

文档待完成。

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity20

Early-stage or recently created project

 Bus Factor1

Top contributor holds 54.5% 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/a1abbba12e43f03842896dd66300a5c32c5e464a4aedfa78d584e6576839e2ff?d=identicon)[MatheusFelipe](/maintainers/MatheusFelipe)

---

Top Contributors

[![ericyzhu](https://avatars.githubusercontent.com/u/1786762?v=4)](https://github.com/ericyzhu "ericyzhu (6 commits)")[![MatheusFelipeMarinho](https://avatars.githubusercontent.com/u/42944045?v=4)](https://github.com/MatheusFelipeMarinho "MatheusFelipeMarinho (3 commits)")[![FCMHUB](https://avatars.githubusercontent.com/u/33237325?v=4)](https://github.com/FCMHUB "FCMHUB (2 commits)")

### Embed Badge

![Health badge](/badges/matheus-carmo-auth-3/health.svg)

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

###  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)
