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

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

denept/thinkcms-auth
====================

The ThinkPHP5 thinkcms-auth Package.

06PHP

Since Jun 16Pushed 5y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

thinkphp5.1 权限认证 RBAC
=====================

[](#thinkphp51-权限认证-rbac)

安装
--

[](#安装)

```
> composer require denept/thinkcms-auth

```

v1.0.0
------

[](#v100)

配置 1.0.0
--------

[](#配置-100)

```
'thinkcms' =>[
        'style_directory' => '/static/admin/',
        'session_prefix'  => 'auth_',
  ]

```

可以不配置 配置以后Js css文件需要放到配置的目录里

手动加入日志 1.0.0
------------

[](#手动加入日志--100)

```
    $auth = new Auth();
    $auth->admin = $list['user_name'];
    $auth->createLog('管理员[ {name} ]偷偷的进入后台了,','后台登录');

```

视图调用
----

[](#视图调用)

```
     public function _empty($name)
        {
            $auth =  new \thinkcms\auth\Auth();
            $auth = $auth->autoload($name);
            if($auth){
                if(isset($auth['code'])){
                    return json($auth);
                }elseif(isset($auth['file'])){
                    return $auth['file'];
                }
                $this->view->engine->layout(false);
                return $this->fetch($auth[0],$auth[1]);
            }
            return abort(404,'页面不存在');
        }

```

在模块中创建一个Auth控制器，把\_empty方法复制上去，这样就可以访问以下视图

- /auth/role.html 角色列表
- /auth/roleAdd.html 角色添加
- /auth/roleEdit.html 角色修改
- /auth/authorize/id/2.html 权限设置
- /auth/menu.html 菜单列表
- /auth/menuAdd.html 菜单增加
- /auth/menuEdit.html 菜单修改
- /auth/log.html 行为日志
- /auth/viewLog.html 查看日志
- /auth/clear.html 清空日志
- /auth/adminAuthorize.html 独立权限

权限认证
----

[](#权限认证)

```
     public function __construct()
        {
            parent::__construct();
            $auth                   = new Auth();
            $auth->noNeedCheckRules = ['index/index/index','index/index/home'];
            $auth->log              = true;                 // 日志开关默认true
            $user                   = $auth::is_login();

            if($user){//用户登录状态
                $this->uid = $user['uid'];
                if(!$auth->auth()){
                    return $this->error("你没有权限访问！");
                }
            }else{
                return $this->error("您还没有登录！",url("publics/login"));
            }
        }

```

这里在公共控制器上加入验证即可

\##管理员独立权限

```
 url('auth/adminAuthorize',['id' => '用户ID','name'=>'用户昵称'])

```

授权菜单
----

[](#授权菜单)

```
 Auth::menuCheck();

```

这个方法返回授权及非隐藏的所有菜单，这样我们后台的菜单就可以根据管理员的权限来来展示授权的目录

mysql文件
-------

[](#mysql文件)

```
dbo_action_log.sql
dbo_auth_access.sql
dbo_auth_role.sql
dbo_auth_role_user.sql
dbo_auth_rule.sql
dbo_menu.sql

```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

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/b40ead017aefaa01d846d59a77860dd5e2dbebeea91d18e918d01601dae9f819?d=identicon)[denept](/maintainers/denept)

---

Top Contributors

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

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/denept-thinkcms-auth/health.svg)](https://phpackages.com/packages/denept-thinkcms-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)
