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

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

myttyy/thinkphp-auth
====================

适用于thinkPHP框架的权限认证库,mAuthentication Library for ThinkPHP Framework

2.0.1(6y ago)10606[1 issues](https://github.com/myttyy/thinkphp-auth/issues)Apache-2.0PHPPHP &gt;=7.1

Since Apr 22Pushed 6y ago2 watchersCompare

[ Source](https://github.com/myttyy/thinkphp-auth)[ Packagist](https://packagist.org/packages/myttyy/thinkphp-auth)[ RSS](/packages/myttyy-thinkphp-auth/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

### Thinkphp Auth权限认证类

[](#thinkphp-auth权限认证类)

2019年5月20日 17:10:54

- Thinkphp6.0请使用最新版2.\*版

```
 "require": {
    "php": ">=7.1",
    "topthink/framework": ">=thinkphp5.1.*" //  或者 "topthink/framework": ">=6.0.*-dev",
 },

```

### 功能特性：

[](#功能特性)

1.是对规则进行认证，不是对节点进行认证。用户可以把节点当作规则名称实现对节点进行认证。

```
$auth=new Auth();
$auth->check('规则名称','用户id')
```

2.可以同时对多条规则进行认证，并设置多条规则的关系（or或者and）

```
$auth=new Auth();// Auth::instance
$auth->check('规则1,规则2','用户id','and')
```

> 第三个参数可选，枚举值： or 、and 第三个参数为and时表示，用户需要同时具有规则1和规则2的权限; 当第三个参数为or时，表示用户值需要具备其中一个条件即可。默认为or

3.一个用户可以属于多个用户组(think\_auth\_group\_access表 定义了用户所属用户组)。我们需要设置每个用户组拥有哪些规则(think\_auth\_group 定义了用户组权限)

4.支持规则表达式。 在think\_auth\_rule 表中定义一条规则时，如果type为1， condition字段就可以定义规则表达式。 如定义{score}&gt;5 and {score}&lt;100 表示用户的分数在5-100之间时这条规则才会通过。

### 数据库

[](#数据库)

```
-- ----------------------------
-- think_auth_rule，规则表，
-- id:主键，name：规则唯一标识, title：规则中文名称 status 状态：为1正常，为0禁用，condition：规则表达式，为空表示存在就验证，不为空表示按照条件验证
-- ----------------------------
DROP TABLE IF EXISTS `think_auth_rule`;
CREATE TABLE `think_auth_rule` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`name` char(80) NOT NULL DEFAULT '',
`title` char(20) NOT NULL DEFAULT '',
`type` tinyint(1) NOT NULL DEFAULT '1',
`status` tinyint(1) NOT NULL DEFAULT '1',
`condition` char(100) NOT NULL DEFAULT '', # 规则附件条件,满足附加条件的规则,才认为是有效的规则
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------
-- think_auth_group 用户组表，
-- id：主键， title:用户组中文名称， rules：用户组拥有的规则id， 多个规则","隔开，status 状态：为1正常，为0禁用
-- ----------------------------
DROP TABLE IF EXISTS `think_auth_group`;
CREATE TABLE `think_auth_group` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`title` char(100) NOT NULL DEFAULT '',
`status` tinyint(1) NOT NULL DEFAULT '1',
`rules` char(80) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------
-- think_auth_group_access 用户组明细表
-- uid:用户id，group_id：用户组id
-- ----------------------------
DROP TABLE IF EXISTS `think_auth_group_access`;
CREATE TABLE `think_auth_group_access` (
`uid` mediumint(8) unsigned NOT NULL,
`group_id` mediumint(8) unsigned NOT NULL,
UNIQUE KEY `uid_group_id` (`uid`,`group_id`),
KEY `uid` (`uid`),
KEY `group_id` (`group_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
```

### composer安装

[](#composer安装)

```
composer require myttyy/thinkphp-auth

```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity55

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

Total

2

Last Release

2550d ago

Major Versions

1.0.6 → 2.0.12019-05-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/077f5e5135eb16889a4b9c77d9f09a715e62acf5b5ba2ce5c545f50ffa5799d9?d=identicon)[myttyy](/maintainers/myttyy)

---

Top Contributors

[![myttyy](https://avatars.githubusercontent.com/u/19262805?v=4)](https://github.com/myttyy "myttyy (5 commits)")

---

Tags

authuserthinkphp

### Embed Badge

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

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

###  Alternatives

[lab404/laravel-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

2.3k16.4M48](/packages/lab404-laravel-impersonate)[amnah/yii2-user

Yii 2 user authentication module

252225.7k3](/packages/amnah-yii2-user)[sarav/laravel-multiauth

A Simple Laravel Package for handling multiple authentication

5030.7k](/packages/sarav-laravel-multiauth)[rickycezar/laravel-jwt-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

24117.6k](/packages/rickycezar-laravel-jwt-impersonate)[saeven/zf3-circlical-user

Complete user entity, rights, and access module for Laminas

3718.7k](/packages/saeven-zf3-circlical-user)[hapidjus/laravel-impersonate-ui

UI for 404labfr/laravel-impersonate

371.5k](/packages/hapidjus-laravel-impersonate-ui)

PHPackages © 2026

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