Yii Framework Forum: [Extension] Auth - Yii Framework Forum

Jump to content

  • (7 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

[Extension] Auth A modern and reponsive user interface for CAuthManager Rate Topic: ***** 2 Votes

#21 User is offline   Tahir Yasin 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 29-November 11

Posted 07 February 2013 - 01:06 AM

View PostStefano Mtangoo, on 03 February 2013 - 02:38 PM, said:

I use the following in config/main.php

return array(
  'modules' => array(
    'auth',
  ),
  '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',
    ),
  ),
);


I get error


If I comment line
'admins'=>array('admin', 'foo', 'bar'), // users with full access
error goes off. Is this a bug?



Update your authManager array like this

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

0

#22 User is offline   nath-0 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 81
  • Joined: 12-October 12
  • Location:switzerland

Posted 07 February 2013 - 05:56 AM

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 :

Quote

WebUser component is not an instance of AuthWebUser.


HOw can I do?

Thanks

Nath
0

#23 User is offline   Kjell Einar Skutle 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 30-November 11
  • Location:Norway

Posted 08 February 2013 - 09:55 AM

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?
0

#24 User is offline   Nisanth thulasi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 10-July 12
  • Location:Kochi

Posted 09 February 2013 - 02:14 AM

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

3) 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.
				)
    	),

Thanks
Nisanth Thulasi
4

#25 User is offline   yiipas 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 29-January 13

Posted 11 February 2013 - 09:39 AM

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
0

#26 User is offline   seobot 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 20-October 12
  • Location:Russia

Posted 14 February 2013 - 03:30 AM

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

#27 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 636
  • Joined: 29-November 08
  • Location:Paris, France

Posted 14 February 2013 - 10:07 AM

Hi seoboot,
just to access the route 'auth': For instance http://localhost/fol...ndex.php?r=auth

ciao
8)
0

#28 User is offline   mintaraga 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 16-April 10
  • Location:Tanggerang, Banten

Posted 16 February 2013 - 12:55 AM

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

#29 User is offline   cappadochian 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 147
  • Joined: 02-January 11

Posted 19 February 2013 - 04:47 AM

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
0

#30 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 636
  • Joined: 29-November 08
  • Location:Paris, France

Posted 19 February 2013 - 02:24 PM

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)
0

#31 User is offline   cappadochian 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 147
  • Joined: 02-January 11

Posted 19 February 2013 - 02:38 PM

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... :/?
0

#32 User is offline   Thiago Prado 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 27-August 12

Posted 23 February 2013 - 11:18 AM

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."
0

#33 User is offline   Daniel 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 214
  • Joined: 26-September 09

Posted 23 February 2013 - 06:45 PM

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

View PostThiago Prado, on 23 February 2013 - 11:18 AM, said:

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

0

#34 User is offline   cappadochian 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 147
  • Joined: 02-January 11

Posted 24 February 2013 - 07:58 AM

View PostThiago Prado, on 23 February 2013 - 11:18 AM, said:

Hi I can't login with the database users
...
I always get "Incorrect username or password."

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

#35 User is offline   K3n91C62n 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 05-February 13

Posted 25 February 2013 - 01:58 AM

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

#36 User is offline   BorisK 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 07-March 13

Posted 07 March 2013 - 05:28 PM

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?"
0

#37 User is offline   HenryJ 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 08-March 13

Posted 08 March 2013 - 10:24 PM

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
0

#38 User is offline   Yerlt 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 16-December 12

Posted 09 March 2013 - 04:08 AM

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?
0

#39 User is offline   kaushik php 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 13-March 13

Posted 13 March 2013 - 08:51 AM

View PostChris83, on 02 January 2013 - 04:45 AM, said:

Hey All,

This is the thread for discussing my latest extension, Auth:
http://www.yiiframew.../extension/auth

Feel free to post any questions you have regarding extension below.



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

#40 User is offline   flaho 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 22-March 13
  • Location:Paris

Posted 22 March 2013 - 09:32 AM

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
0

Share this topic:


  • (7 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users