PHPackages                             crisu83/yii-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. crisu83/yii-auth

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

crisu83/yii-auth
================

Web UI for the authorization manager of Yii PHP framework.

1.7.0(12y ago)13439.8k—0%88[8 issues](https://github.com/Crisu83/yii-auth/issues)[2 PRs](https://github.com/Crisu83/yii-auth/pulls)BSD-3-ClausePHP

Since Sep 27Pushed 8y ago29 watchersCompare

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

READMEChangelogDependencies (2)Versions (5)Used By (0)

yii-auth
========

[](#yii-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 (CAuthManager). You can read more about Yii's authorization manager in the framework documentation under [Authentication and Authorization](http://www.yiiframework.com/doc/guide/1.1/en/topics.auth#role-based-access-control).

Auth was developed to provide a modern and responsive user interface for managing user permissions in Yii projects. To achieve its goals it was built using my popular [Twitter Bootstrap extension](http://www.yiiframework.com/extension/bootstrap).

Auth is written according to Yii's conventions and it follows the [separation of concerns](http://en.wikipedia.org/wiki/Separation_of_concerns) priciple and therefore it doesn't require you to extend from its classes. Instead it provides additional functionality for the authorization manager through a single behavior.

### Demo

[](#demo)

You can try out the live demo [here](http://www.cniska.net/yii-auth/).

### Requirements

[](#requirements)

- [Twitter Bootstrap extension for Yii](http://www.yiiframework.com/extension/bootstrap) version 2.0.0 or above

Usage
-----

[](#usage)

### Setup

[](#setup)

Download the latest release from [Yii extensions](http://www.yiiframework.com/extension/auth).

Unzip the module under ***protected/modules/auth*** and add the following to your application config:

```
return array(
  'modules' => array(
    'auth',
  ),
  'components' => array(
    'authManager' => array(
      .....
      'behaviors' => array(
        'auth' => array(
          'class' => 'auth.components.AuthBehavior',
        ),
      ),
    ),
    'user' => array(
      'class' => 'auth.components.AuthWebUser',
      'admins' => array('admin', 'foo', 'bar'), // users with full access
    ),
  ),
);
```

***protected/config/main.php***

Please note that while the module doesn't require you to use a database, if you wish to use ***CDbAuthManager*** you need it's schema (it can be found in the framework under web/auth).

### Configuration

[](#configuration)

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

```
'auth' => array(
  'strictMode' => true, // when enabled authorization items cannot be assigned children of the same type.
  'userClass' => 'User', // 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.
  'defaultLayout' => 'application.views.layouts.main', // the layout used by the module.
  'viewDir' => null, // the path to view files to use with this module.
),
```

#### Enabling caching

[](#enabling-caching)

To enable caching for ***CDbAuthManager*** you can use ***CachedDbAuthManager*** that provides caching for access checks. Here's an example configuration for the component:

```
'authManager'=>array(
  'class'=>'auth.components.CachedDbAuthManager',
  'cachingDuration'=>3600,
),
```

### Checking access

[](#checking-access)

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

```
if (Yii::app()->user->checkAccess('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 [Authentication and Authorization](http://www.yiiframework.com/doc/guide/1.1/en/topics.auth#role-based-access-control).

#### 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. You can also use a wildcard ***controllerId.***\* instead of the actionId to cover all actions in the controller or ***module.***\* instead of the controllerId to cover all controllers in the module.

```
public function filters()
{
  return array(
    array('auth.filters.AuthFilter'),
  );
}
```

For more information on how filters work refer to the framework documentation on [Controllers](http://www.yiiframework.com/doc/guide/1.1/en/basics.controller#filter).

### Internationalization

[](#internationalization)

Do you wish to provide a translation for Auth? If so, please do a pull request for it. Translations should be placed in the messages folder under a folder named according to its locale (e.g. en\_us).

### Note

[](#note)

Note: Version 1.0.6-wip use and require yiistrap!! yiistrap is next generation yii-bootsrap

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity66

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

Total

2

Last Release

4609d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab3becb3323ceb956c661f3e6ef4312dcd00ec4ba03d1bba5fcef793f5c4286d?d=identicon)[crisu83](/maintainers/crisu83)

---

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/crisu83-yii-auth/health.svg)

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

###  Alternatives

[2amigos/yii2-usuario

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

298275.5k14](/packages/2amigos-yii2-usuario)[amnah/yii2-user

Yii 2 user authentication module

252225.7k3](/packages/amnah-yii2-user)[developeruz/yii2-db-rbac

Dynamic control of access rights in YII2

11097.4k5](/packages/developeruz-yii2-db-rbac)[hasinhayder/tyro

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

6712.1k2](/packages/hasinhayder-tyro)[efficiently/authority-controller

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

15533.2k](/packages/efficiently-authority-controller)[potievdev/slim-rbac

Role Based Access Control middleware for Slim 3

345.5k1](/packages/potievdev-slim-rbac)

PHPackages © 2026

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