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

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

binn/yii2-auth
==============

Web UI for the authorization manager of Yii PHP framework.

1.7.0(12y ago)512.3k2[1 PRs](https://github.com/arturf/yii2-auth/pulls)BSD-3-ClausePHP

Since Sep 27Pushed 3y ago3 watchersCompare

[ Source](https://github.com/arturf/yii2-auth)[ Packagist](https://packagist.org/packages/binn/yii2-auth)[ RSS](/packages/binn-yii2-auth/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (2)Versions (6)Used By (0)

yii2-auth
=========

[](#yii2-auth)

Auth is a module for the [Yii PHP framework](http://www.yiiframework.com) that provides a web user interface for Yii's built-in authorization manager (\\yii\\rbac\\BaseManager). You can read more about Yii's authorization manager in the framework documentation under [Authorization](http://www.yiiframework.com/doc-2.0/guide-security-authorization.html#role-based-access-control-rbac).

Auth based on original code of [yii-auth](https://github.com/crisu83/yii-auth) extension and fully rewrited for using with Yii 2. Also fork contain all original releases for Yii 1.x.

**At this moment module supports only DbManager.**

### Demo

[](#demo)

Coming soon.

Usage
-----

[](#usage)

### Setup

[](#setup)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Add

```
"binn/yii2-auth": "*"

```

to the require section of your `composer.json` file.

Add module to application config and configure `authManager` component:

```
return [
    'components' => [
        'authManager' => [
            'class' => 'auth\components\DbManager', // or 'auth\components\PhpManager'
        ],
        // ...
    ],
    'modules' => [
        'auth' => [
            'class' => 'auth\Module',
        ],
    ],
];
```

Please note that while the module doesn't require you to use a database, if you wish to use ***yii\\rbac\\DbManager*** you need it's schema (it can be found in the framework under `yii\rbac\migrations`).

### Configuration

[](#configuration)

Configure the module to suit your needs. Here's a list of the available configurations (with default values).

```
'auth' => array(
  'userClass' => Yii::$app->user->identityClass, // the name of the user model class.
  'userIdColumn' => 'id', // the name of the user id column.
  'userNameColumn' => 'name', // the name of the user name column.
  'applicationControllers' => [], // the path to controllers files that will be using for generates permissions.
  'admin' => [], // users with full access to module.
  'accessFilterBehavior' => [], Configuration for custom access filter.
),
```

### Checking access

[](#checking-access)

When you wish to check if the current user has a certain permission you can use the ***User::can()*** method which can be access from anywhere in your application through ***Yii::$app*** like so:

```
if (Yii::$app->user->can('itemName')) // itemName = name of the operation
{
  // access is allowed.
}
```

In order to keep your permissions dynamic you should never check for a specific role or task, instead you should always check for an operation. For more information on Yii's authorization manager refer to the framework documentation on [Authorization](http://www.yiiframework.com/doc-2.0/guide-security-authorization.html#role-based-access-control-rbac).

#### Checking access using a filter

[](#checking-access-using-a-filter)

You can also use a filter to automatically check access before controller actions are called. Operations used with this filter has to be named as follows ***(moduleId.)controllerId.actionId***, where ***moduleId*** is optional.

For example

```
public function behaviors()
{
    return [
        'access' => [
            'class' => AccessControl::className(),
                'rules' => [
        		    [
        			    'allow' => true,
        			    'actions' => ['error', 'login', 'logout'],
                    ],
                    [
                        'allow' => true,
                        'roles' => [$this->getRuleName($this->action->id)],
                    ],
                    [
                        'allow' => true,
                        'matchCallback' => function () {
                            return !Yii::$app->user->isGuest ? !empty(Yii::$app->user->identity->isAdmin) : false;
                    },
                ],
            ],
        ],
    ];
}
```

For more information on how filters work refer to the framework documentation on [Controllers](http://www.yiiframework.com/doc-2.0/guide-structure-filters.html).

Versioning
----------

[](#versioning)

Because Auth contain all versions from original library be careful with versions.

Version 1.x - for Yii 1.x Version 2.x - for Yii 2.x

Contributing
------------

[](#contributing)

Please, send any issues and PR only for 2.x version. For original Yii 1.x module contribute to [yii-auth](https://github.com/crisu83/yii-auth)

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 78.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.

###  Release Activity

Cadence

Every ~225 days

Total

5

Last Release

3764d ago

Major Versions

1.7.0 → v2.0.0-rc2014-10-04

### Community

Maintainers

![](https://www.gravatar.com/avatar/3892dbe959744c000bdad73d62c4e6c150f8eb8efd5c35a24eb5ffdb38b3a2b5?d=identicon)[arturf](/maintainers/arturf)

---

Top Contributors

[![cniska](https://avatars.githubusercontent.com/u/1044868?v=4)](https://github.com/cniska "cniska (113 commits)")[![Yiivgeny](https://avatars.githubusercontent.com/u/1321010?v=4)](https://github.com/Yiivgeny "Yiivgeny (5 commits)")[![devpull](https://avatars.githubusercontent.com/u/20315481?v=4)](https://github.com/devpull "devpull (4 commits)")[![magefad](https://avatars.githubusercontent.com/u/1182744?v=4)](https://github.com/magefad "magefad (3 commits)")[![madand](https://avatars.githubusercontent.com/u/2280844?v=4)](https://github.com/madand "madand (3 commits)")[![teian](https://avatars.githubusercontent.com/u/611264?v=4)](https://github.com/teian "teian (3 commits)")[![izemize](https://avatars.githubusercontent.com/u/1323246?v=4)](https://github.com/izemize "izemize (2 commits)")[![fierwebdesign](https://avatars.githubusercontent.com/u/2226998?v=4)](https://github.com/fierwebdesign "fierwebdesign (2 commits)")[![softark](https://avatars.githubusercontent.com/u/342857?v=4)](https://github.com/softark "softark (1 commits)")[![m-nel](https://avatars.githubusercontent.com/u/1463359?v=4)](https://github.com/m-nel "m-nel (1 commits)")[![justLuiz](https://avatars.githubusercontent.com/u/1229702?v=4)](https://github.com/justLuiz "justLuiz (1 commits)")[![almix](https://avatars.githubusercontent.com/u/376809?v=4)](https://github.com/almix "almix (1 commits)")[![mve-it-solutions](https://avatars.githubusercontent.com/u/3631510?v=4)](https://github.com/mve-it-solutions "mve-it-solutions (1 commits)")[![nineinchnick](https://avatars.githubusercontent.com/u/795177?v=4)](https://github.com/nineinchnick "nineinchnick (1 commits)")[![robregonm](https://avatars.githubusercontent.com/u/1051457?v=4)](https://github.com/robregonm "robregonm (1 commits)")[![ryusoft](https://avatars.githubusercontent.com/u/2564357?v=4)](https://github.com/ryusoft "ryusoft (1 commits)")[![sitawit](https://avatars.githubusercontent.com/u/3954702?v=4)](https://github.com/sitawit "sitawit (1 commits)")

---

Tags

Authenticationrbacyii

### Embed Badge

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

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

###  Alternatives

[crisu83/yii-auth

Web UI for the authorization manager of Yii PHP framework.

13539.9k](/packages/crisu83-yii-auth)[2amigos/yii2-usuario

Highly customizable and extensible user management, authentication, and authorization Yii2 extension

297285.0k16](/packages/2amigos-yii2-usuario)[amnah/yii2-user

Yii 2 user authentication module

257232.4k3](/packages/amnah-yii2-user)[hasinhayder/tyro

Tyro - The ultimate Authentication, Authorization, and Role &amp; Privilege Management solution for Laravel 12 &amp; 13

6804.7k6](/packages/hasinhayder-tyro)[developeruz/yii2-db-rbac

Dynamic control of access rights in YII2

11099.1k5](/packages/developeruz-yii2-db-rbac)[efficiently/authority-controller

AuthorityController is an PHP authorization library for Laravel 5 which restricts what resources a given user is allowed to access.

15433.2k](/packages/efficiently-authority-controller)

PHPackages © 2026

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