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

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

edwinhuish/think-auth
=====================

Thinkphp 6 RBAC 权限管理

v1.0.5(3y ago)014MITPHPPHP &gt;=7.4

Since Oct 29Pushed 3y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (3)Versions (7)Used By (0)

Think Auth (ThinkPHP 6 Package)
===============================

[](#think-auth-thinkphp-6-package)

基于角色的权限的简洁而灵活的方式。

Contents
--------

[](#contents)

- [安装](#%E5%AE%89%E8%A3%85)
- [自定义模型](#%E8%87%AA%E5%AE%9A%E4%B9%89%E6%A8%A1%E5%9E%8B)

    - [Role](#role)
    - [Permission](#permission)
    - [User](#user)
- [使用](#%E4%BD%BF%E7%94%A8)

    - [概念](#%E6%A6%82%E5%BF%B5)
    - [检查用户是否拥有权限](#%E6%A3%80%E6%9F%A5%E7%94%A8%E6%88%B7%E6%98%AF%E5%90%A6%E6%8B%A5%E6%9C%89%E6%9D%83%E9%99%90)
    - [使用中间件](#%E4%BD%BF%E7%94%A8%E4%B8%AD%E9%97%B4%E4%BB%B6)
- [故障排除](#%E6%95%85%E9%9A%9C%E6%8E%92%E9%99%A4)
- [License](#license)
- [Contribution guidelines](#contribution-guidelines)

安装
--

[](#安装)

1. 运行 `composer require edwinhuish/think-auth`
2. 使用 `php think auth:publish` 在项目内新增 `/config/auth.php` 以及在 `/database/migrations/` 内新增迁移文件。
3. 配置 `config/auth.php`，并按需修改迁移文件，`user` 表的迁移默认已注释，请根据实际需求修改。
4. 运行 `php think migrate:run` 生成数据表。

自定义模型
-----

[](#自定义模型)

### Role

[](#role)

使用以下示例在`app\model\Role.php`内创建角色模型：

```
