[Extension] Auth

Update your authManager array like this


'authManager' => array(

    'behaviors' => array(

        array(

            'class' => 'auth.components.AuthBehavior',

            'admins' => array('admin', 'foo', 'bar'), // users with full access

        ),

    ),

),

Hello,

Somone knoe how to extends the class AuthWebUser ?

I did that :

main.php




'user'=>array(

            'class' => 'QWebUser',// 'auth.components.AuthWebUser',//'QWebUser',

			// disable cookie-based authentication

			'allowAutoLogin'=>false,

            'authTimeout'=>120000,

		),



and I extends My class QWebUSer :




class QWebUser extends AuthWebUser

{



I got this error :

HOw can I do?

Thanks

Nath

In srbac there is an option to set ‘debug’=>true in module config, which is very useful when I run benchmark tests for instance. Is there any way to do something similar in auth?

  1. Download the latest release from Yii extensions Auth.

and placed under folder protected/modules, if not please create one folder named modules

2)Then protected/config/main.php

on module array add




	'modules'=>array(

      		.........

      		'auth', 

      		

  		),

OR





'modules'=>array(

 	.........


  '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.

 	'appLayout' => 'application.views.layouts.main', // the layout used by the module.

	'viewDir' => null, // the path to view files to use with this module.

  ),


  ),



in components array





  'components' => array(

    'authManager' => array(

 	......

      'behaviors' => array(

        'auth' => array(

          'class' => 'auth.components.AuthBehavior',

          'admins' => array('admin', 'foo', 'bar'), // users with full access

        ),

      ),

    ),

    'user' => array(

      'class' => 'auth.components.AuthWebUser',

    ),

  ),



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/schema-mysql.sql(if mysql is using), and it import to your db).

	also change the authManager array to 



   'authManager' => array(

  		'class' => 'CDbAuthManager',

  		'connectionID' => 'db',

  		'behaviors' => array(

			'auth.components.AuthBehavior',

  		),

      	),

	

and in main controller please use




	public function filters()

	{

  	return array(

    	array('auth.filters.AuthFilter'),

  	);

	}

auth module will ready to use index.php?r=auth with normal template

  1. if you want to use bootstrap pleas do as below

    download bootstrap from http://www.yiiframew…nsion/bootstrap and placed under protected/extension/bootstrap

    then copy the theme from bootstrap to theme folder under you webapplication/themes/

    Top of the protected/config/main.php add


	Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');

in components array




   'bootstrap'=>array(

				'class'=>'bootstrap.components.Bootstrap',

  		),

and change appLayout from auth array as below



    modules =array(

		

		auth=>array(

  		......

		'appLayout' => 'webroot.themes.theme.views.layouts.main', // the layout used by the module.

				)

    	),



Is there a way to get the Role of the logged in user just like you could in Rights with


$roles=Rights::getAssignedRoles(Yii::app()->user->Id);

I need it in order to show a different layout depending on the user role

I could not find any where how to get to the admin panel of the module, as in the demo mode.

Hi seoboot,

just to access the route ‘auth’: For instance http://localhost/fol...ndex.php?r=auth

ciao

8)

is there any way to auto generate task based on the action in controller using auth extension? like right extension.

Hi Guys,

fantastic extension!

  1. on Assignments page, all users are listed with Assigned items: Administrator

  2. I can’t see the CRUD buttons at the end of the lines

  3. there are no explanations of different items like on the demo site:

Authenticated: role

Administer posts: task

Post wildcard: operation

can you please try to explain me what can be the problem?

thanks for helping!

BR

c

Hi cappadochian,

The first problem is fixed on the lastest version (that you can from github). There’s no official release yet…

Then for the second problem, did you install the yii-bootstrap extension ? it is required for the page to display correctly.

Hope this helps

ciao

B)

Hi Raoul,

thank you so much. I’ll grab the latest release then from github. Yes of course, I have installed the yii bootstrap extension. I’ve got a notice “trying to get property of non-object” when I wanted to use the CSS but I’ve changed php.ini error reporting to … ~E_NOTICE so now it seems good. it seems the css is OK now, except the buttons. but maybe this notice has to do something with the missing CRUD buttons? I think the problem was something with


<link href="<?php echo Yii::app()->theme->baseUrl; ?>/css/...

should I turn back error reporting and try to find out what is wrong with this part? but I have no clue… that’s why I’ve turned error_reporting off… :/?

Hi I can’t login with the database users

My main.php





'import'=>array(

		'application.models.*',

		'application.components.*',

		'ext.giix-components.*', // giix components

		'application.modules.auth.*',

		'application.modules.auth.components.*',

		),


'modules'=>array(

		'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.

		'appLayout' => 'application.views.layouts.main', // the layout used by the module.

		'viewDir' => null, // the path to view files to use with this module.

		),

...


'components'=>array(

	

	'db'=>array(

			'class'=>'CDbConnection',

			'connectionString' => 'mysql:host=localhost;dbname=plataforma',

			'emulatePrepare' => true,

			'username' => 'root',

			'password' => '*******',

			'charset' => 'utf8',

			),

	

	'authManager' => array(

			'class' => 'CDbAuthManager',

			'connectionID' => 'db',

			'behaviors' => array(

                        'auth.components.AuthBehavior',

			),

			),

		

	'user'=>array(

			'class' => 'auth.components.AuthWebUser',

			'allowAutoLogin'=>true,

			),

			

			...




The UserIdentity.php




class UserIdentity extends CUserIdentity

{

	/**

	 * Authenticates a user.

	 * The example implementation makes sure if the username and password

	 * are both 'demo'.

	 * In practical applications, this should be changed to authenticate

	 * against some persistent user identity storage (e.g. database).

	 * @return boolean whether authentication succeeds.

	 */

	private $_id;

    public function authenticate()

    {

        $record=User::model()->findByAttributes(array('username'=>$this->username));

        if($record===null)

            $this->errorCode=self::ERROR_USERNAME_INVALID;

        else if($record->password!==md5($this->password))

            $this->errorCode=self::ERROR_PASSWORD_INVALID;

        else

        {

            $this->_id=$record->id;

            $this->setState('title', $record->title);

            $this->errorCode=self::ERROR_NONE;

        }

        return !$this->errorCode;

    }

 

    public function getId()

    {

        return $this->_id;

    }

}



My User table




CREATE TABLE `user` (

  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,

  `name` varchar(200) DEFAULT NULL,

  `username` varchar(100) DEFAULT NULL,

  `password` varchar(100) DEFAULT NULL,

  `role` varchar(100) DEFAULT NULL,

  PRIMARY KEY (`id`)

) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;



I always get "Incorrect username or password."

Hi,

I ever got this problem. In my case was that the password was md5 twice since I made a mistake on the saving process. I always md5 my password, so every time I save the model, the password is being md5 again and again. Check your saving process of your user.

Cheers,

Daniel

do you have a User model? UPDATE: I have checked and it seems it’s not really necessary, at least for me.

Yes, if you use auth, CWebUser handles login.

if you have this:


`username` varchar(100) DEFAULT NULL,

i guess this is not okay:


'userNameColumn' => 'name',

and should be this:


'userNameColumn' => 'username',

but maybe it has nothing to do with “Incorrect username or password.” I don’t know that.

UPDATE:


'userNameColumn' => 'username',

the documentation is a little bit confusing, it definitely has to be like this, but it’s only for the proper working of the auth module it has nothing to do with user login.

Hi, Chris83

how to set the module under a sub-url,

just like your ‘rights’ module, with ‘baseUrl’ config

i really want it be access like ‘/admin/auth’

Hi, Chris83

Nice extension. But I have a few comment:

  1. The error in a xhtml-page. To fix this bug I removed empty (second) line in the modules/auth/views/layouts/main.php

  2. The error, when I tried to create anything. To fix this bug I made dir protected/data && chmod

  3. The error with module yii-auth. To fix this bug I changed "extends" from "CWebUser" to "WebUser" in the modules/auth/components/AuthWebUser.php and changed "userNameColumn" from "name" to "username" in the config.

  4. The nonsense with Yii::app()->user->isAdmin in the modules/auth/widgets/AuthAssignmentViewColumn.php and modules/auth/widgets/AuthAssignmentItemsColumn.php . Probably, you meant not "Am I admin?", but "Is that user is admin?"

Auth looks like an awesome extension. Thanks Chris.

I’d like to run the demo (at www cniska net / ii-auth) on my local XAMPP Windows machine. It looks like all of the code for this is included in the github package yii-auth-master in the demo folder.

The protected/config/main.php file is missing however. I’m new to Yii and don’t have any idea what this should contain. Have tried to cobble one up for several hours with no success.

If someone could supply a working main.php I would greatly appreciate it. Or, if I’m incorrect about this being standalone demo capable, please let me know.

Thanks

Hi there!

Thanks for this awesome extension!

But i need a quick tip. How the heck can i set default roles? I could not find anything… :(

I also tried the main.php-config:




'authManager' => array(

         'behaviors' => array('auth.components.AuthBehavior',), 

         'class'=>'auth.components.CachedDbAuthManager',

         'cachingDuration'=>3600,

         'defaultRoles'=>array('StandardUser'),

),

Any ideas?

Hi Chris,

Thank you for Auth extension,

I am new in Yii framework, when i install auth extesion I found error.

its good if provide extension with demo project.

I just installed and updated some files.

When I try ?r=auth I get an error:

Error 500

Property "AuthModule.appLayout" is not defined.

Copyright © 2013 by My Company.

All Rights Reserved.

Any idea ?

thanks