auth

A modern and responsive user interface for Yii's authorization manager
79 followers

Auth is a new module from the creator of the popular Rights module for managing user permissions in Yii applications. It's a completely new, modern and responsive user interface for Yii's authorization manager (CAuthManager) built using the also popular Bootstrap extension.

Auth is NOT a new version of Rights, even though those familiar with Rights might feel at home using it. It was developed from scratch following Yii's conventions and it's both easier to use and extend.

Links

Requirements

Usage

You can read about how to setup and use this module from its README on GitHub.

Changes

v1.6.0 (Jan 23, 2013)

  • Moved admins to AuthBehavior
  • Change AuthFilter to require login
  • Translation fixes

v1.5.0 (Jan 17, 2013)

  • Change module to only allow admin users
  • Rename translations (e.g. en_us to en)
  • Translation fixes

v1.4.1 (Jan 12, 2013)

  • Fix caching of access checks
  • Add Russian translation (thanks Ragazzo)

v1.4.0 (Jan 12, 2013)

  • Add support for caching access checks
  • Add initial support for CPhpAuthManager
  • Fix capitalization for cyrillic languages
  • Ukranian translation (thanks MadAnd)

v1.3.0 (Jan 4, 2013)

  • Added support for bypassing access checks for certain users
  • Fixed controller ids when translations are enabled

v1.2.1 (Jan 1, 2013)

  • Refactored grid column classes
  • Fixed a minor bug in listing assignments

v1.2.0 (Dec 31, 2012)

  • Added CachedDbAuthManager
  • Added authorization item subcontrollers

v1.1.0 (Dec 30, 2012)

  • PHP 5.3.0 requirement dropped
  • Refactored code

v1.0.0 (Dec 29, 2012)

  • Initial release

Total 20 comments

#13120 report it
schmunk at 2013/05/06 08:12am
@akkumaru: github repos should be working again

from the github support:

Sorry for the trouble! That user and their work should show up fine now (you may need to close your browser and clear your cache first). Please don't hesitate to let us know if you have any questions or concerns.

#13113 report it
akkumaru at 2013/05/06 12:24am
github

What happen to the github link?

#12898 report it
codesutra at 2013/04/19 05:26am
Assign Admin Permissions to user.

Anybody can suggest me, how could i assign admin permissions to some user with extension.

I am not expecting to add that user into the admins array into the config file. :) it would be great if anybody can tell me some thoughts about it.

Thanks in Advance.

Thanks and Regards,

#12886 report it
codesutra at 2013/04/18 12:25am
@Rodrigo Coelho

Thanks for your solution posted in Your text to link here... :)

i have already fixed that issue with your provided solution few days before. but couldn't reply on the thread.

Anyways thanks again for your response.

#12884 report it
Rodrigo Coelho at 2013/04/18 12:11am
@codesutra - Fix for "Property "AuthWebUser.admins" is not defined"

Fixed with:

'components'=>array(
    // ...
    'user'=>array(
        'class' => 'auth.components.AuthWebUser',
        'behaviors' => array(
            'auth' => array(
                'class' => 'auth.components.AuthBehavior',
                'admins' => array('admin'),
            ),
        ),
    ),
    // ...
),
#12766 report it
ramasurf at 2013/04/10 10:24pm
Owner validation

Hi first of all, thanks for the extension. It's really useful, although I dont know how to set owner validation into the yii-auth logic

I always use the below code of validation, it's not a good piece of code because it does not allow the separation of cross-cutting logic.

actionUpdate($id){
$post_model=$this->loadmodel($id);
if($post_model->user_id==Yii::app()->user->getId())
 #do st..
else
 #shame on you
}

please, What is the best way to fulfill my expectations? thanks SERGIO

#12759 report it
codesutra at 2013/04/10 08:42am
" WebUser component is not an instance of AuthWebUser " Execption.

Hey,

i have downloaded yii-auth-1.6.0.zip version of this extension. and done configuration as you have mentioned here.

But when i am trying to access the application i am getting below given exception.

"Property "AuthWebUser.admins" is not defined. "

Any thoughts about it.

Then i temporary commented below given code.

'user' => array( 'class' => 'auth.components.AuthWebUser', //'admins' => array('admin', 'foo', 'bar'), // users with full access ),

And run the app. now its working.

But i am unable to access the magic of this extension yet.Its showing permission error.

Could you please tell me how could i fix it.

And also. in you downloaded extension AuthModule.php is not updated as it is shown here Could you please confirm it.

Looking forward to here from you.

#12704 report it
toph at 2013/04/06 09:50pm
Module-wide rules fix

Any operations named module.* are ignored by this module. In order to fix this the auth/filters/AuthFilter.php file should be altered as follows:

protected function preFilter($filterChain)
{
    ...
    if (($module = $controller->getModule()) !== null){
        $itemName .= $module->getId() . '.';
        if (Yii::app()->user->checkAccess($itemName.'*')) return true;//Add this line
    }
    ...

Awesome extension.

#12367 report it
Nisanth thulasi at 2013/03/16 01:44am
Login captcha

I have strucked in the admin login page that the captcha not showing the image

after i add $publicPages in beforeControllerAction in admin module AdminModule.php

$publicPages = array(
              ......
        'default/captcha',
              ......
            );

Working fine

#12235 report it
OwiecPL1986 at 2013/03/08 01:35pm
Authorise value - another column

Hi,

I need in system authorise by 'id' of user. Not 'name' column.

In AuthWebUser.php in your module you have "$this->setIsAdmin(in_array($this->id, Yii::app()->authManager->admins));".

I have to all the time when i get update change this to "$this->id".

Is it possible to do something with that?

#12067 report it
opus at 2013/02/26 12:11am
Users with full access

Answering my own question. I forgot to assign username in UserIdentity class:

public function authenticate()
    {
        $user=User::model()->findByAttributes(array('username'=>$this->username));
        if($user===null)
            $this->errorCode=self::ERROR_USERNAME_INVALID;
        else if($user->password!==md5($this->password))
            $this->errorCode=self::ERROR_PASSWORD_INVALID;
        else
        {
            $this->_id=$user->id;
            $this->setState('username', $user->username); // Here is what I forgot
            $this->errorCode=self::ERROR_NONE;
        }
        return !$this->errorCode;
    }

AuthWebUser class uses it to assign an admin role. Kind of obvious thing but still I forgot about it while testing.

#12065 report it
opus at 2013/02/25 09:18pm
Users with full access

I can't get it work with assigning user full access. In config I have this:

'authManager' => array(
            'class' => 'CDbAuthManager',
            'connectionID'=>'db',
            'itemTable' => 'tbl_authitem',
            'itemChildTable' => 'tbl_authitemchild',
            'assignmentTable' => 'tbl_authassignment',
            'behaviors' => array(
                'auth' => array(
                    'class' => 'auth.components.AuthBehavior',
                    'admins' => array('admin'), // users with full access
                ),
            ),

but when I log in and check with:

Yii::app()->user->isAdmin//  false

it gives me false and denies from actions untill I write them in filters explicitly. Has anyone faced a similar issue before?

#12011 report it
MaxS at 2013/02/20 09:49am
error page

1) To display the access errors in the view, you need to add error handler (site/error) to the exclusion of filter or add it to role permissions

public function filters()
    {
        return array(
            array('auth.filters.AuthFilter - login, logout, restore, captcha, error'),
        );
    }

2) instead 401 error (Unauthorized) in AuthFilter.php, you need to use 403 (Forbidden)

throw new CHttpException(403, 'Access denied.');

PS: Chris, thx for perfect extension

#11979 report it
fabian.horlacher at 2013/02/18 04:51am
Allowed Actions

There is no allowedActions in the auth extension. Include them in the filters, which are interpreted by the Yii CController.

public function filters()
{
    return array(
        array('auth.filters.AuthFilter - login, test'),
    );
}

Read more in the doc.

#11919 report it
Tahir Yasin at 2013/02/13 12:39am
How to specify Allowed Actions?

Is there a way to specify allowed actions for guest user? Like we did with the great Rights Module.

public function allowedActions() {
    return 'login,logout'; 
}
#11904 report it
yiipas at 2013/02/12 08:15am
Business rules added

Thank you for this great extension. Not sure why there is no support for setting business rules on operations. I added this functionality, feel free to download the fork: https://github.com/kakousis/yii-auth

#11763 report it
nineinchnick at 2013/02/02 04:23am
performance

Hi Chris,

I've got a lot of auth items:

  • 394 auth items
  • 103 assignments
  • 552 parent-child relations

I've noticed that loading the assignment page took very long and made more than 2000 database queries. So I've written an overloaded CDbAuthManager class that will load everything in one (three actually) queries and serve data from a tree like array.

Check it out at SingleDbAuthManager. If that idea will prove itself, maybe it's worth distributing with your auth module.

When using with auth module, just do:

  • add at the top: Yii::import('auth.components.CachedDbAuthManager')
  • switch base class to CachedDbAuthManager

It shouldn't have any drawbacks in my opinion.

#11694 report it
Daniel at 2013/01/27 10:43pm
need user table?

Hi Chris,

Can we use auth without user management/minimum user table? I am a bit confuse.

#11688 report it
schmunk at 2013/01/27 11:04am
Thanks

Does anyone know, if the extension would the extension be compatible with yii-user if it implements this method?

#11687 report it
fad at 2013/01/27 10:53am
is admin user

@schmunk Yii::app()->user->isAdmin

Leave a comment

Please to leave your comment.

Create extension