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

Jump to content

  • (7 Pages)
  • +
  • « First
  • 3
  • 4
  • 5
  • 6
  • 7
  • 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

#81 User is offline   ChipTuner 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 21-May 13

Posted 21 May 2013 - 05:16 AM

Hello!

I'm trying to use auth module with yii-user module in my project. And have a several questions.
User module already have some role assignments (user/administrator). And when i navigate to /user/admin/create (new user creation), i see "Superuser" field. But if i understand clearly, all right management are now going through auth module. Am i right? Do i need to set default "superuser" to no? And how?
And how can i set default assignment user to role when i creating user?
0

#82 User is offline   cico 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 22-December 12

Posted 18 June 2013 - 10:13 AM

Hi to all :)

Thank you Chris83 for this extension.

I have a question for all about this module. You think that i can use this extension with yiimongodbsuite and mongodbauthmanager.

I try to use but i found some erro like for example all user in Assigned items are Administrator (in my admin array i set only my email login -> 'admins' => array('admin@test.com', 'foo', 'bar'))

Let me know if you have suggest :)

Thank you
0

#83 User is offline   cico 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 22-December 12

Posted 18 June 2013 - 05:46 PM

Ok i solved adding (string) before $data->{$this->columId} on widget/AuthAssignmentItemsColumn.php
0

#84 User is offline   Chris83 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 440
  • Joined: 27-February 10
  • Location:Helsinki, Finland

Posted 18 June 2013 - 06:07 PM

View Postcico, on 18 June 2013 - 05:46 PM, said:

Ok i solved adding (string) before $data->{$this->columId} on widget/AuthAssignmentItemsColumn.php

So my extension actually works even with the mongodb auth manager? If so, that's really nice to hear.
Best regards,
Chris

My contribution to the Yii community:
Account | Yiistrap | Auth | Bootstrap | NordCms | Rights | LESS | SEO | Img

Follow me:
Twitter | GitHub | Bitbucket
0

#85 User is offline   Néstor Acevedo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 08-January 13

Posted 01 July 2013 - 09:16 PM

hi.

only superadmin -default admin in main config- is working in all the site. for another things, what i allow not only sa, else admins (RbacAdmin) is displaying a denied access.

i've followed what is written here but still with a 401 error for other users -admins or not admins-

how to set correctly permissions in the controller for not only sa?

thnx
0

#86 User is offline   bitmatix 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 162
  • Joined: 23-March 09

Posted 10 July 2013 - 12:17 PM

Hi,

is there a way to get all users assigned to a specific role?

I have a dropdown in a form where I want to list only users having a specific role.

Cheers!
0

#87 User is offline   Marcus Matos 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 02-November 10

Posted 10 July 2013 - 01:06 PM

View Posttempelfeld, on 12 May 2013 - 12:19 PM, said:

Assign another user (from database) full access to the module yii-auth

I did this as follows way:

1. Create user admin2 in the database.

2. Create operation auth.* and assign it to the role Administrator.

3. Assign the Administrator role to the users admin and admin2.

4. Comment out the following code in auth/AuthModule.php:
/*        
	public function beforeControllerAction($controller, $action)
	{
		if (parent::beforeControllerAction($controller, $action))
		{
			$user = Yii::app()->getUser();

			if ($user instanceof AuthWebUser)
			{
				if ($user->isAdmin)
					return true;
			}
			else
				throw new CException('WebUser component is not an instance of AuthWebUser.');
		}
		throw new CHttpException(401, Yii::t('AuthModule.main', 'Access denied.'));
	}
*/


5. Add the following line in auth/filters/AuthFilter.php as written here:
protected function preFilter($filterChain)
{
    ...
    if (($module = $controller->getModule()) !== null){
        $itemName .= $module->getId() . '.';
        if (Yii::app()->user->checkAccess($itemName.'*')) return true;//Add this line
    }
    ...


6. Add the following code in auth/controllers/AssignmentController.php:
class AssignmentController extends AuthController
{
        // Add this code
        public function filters()
        {
          return array(
            array('auth.filters.AuthFilter'),
          );
        }
        ...



Finish. Now it works as I want. Users admin and admin2 have access to the module yii-auth.

Also the following line in config/main.php no longer needed and I comment out it:
		'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
                        'class' => 'auth.components.AuthWebUser',
                        'behaviors' => array(
                            'auth' => array(
                                'class' => 'auth.components.AuthBehavior',
                                //'admins' => array('admin','admin2'), // Comment out it
                            )
                        ),
		),




Thank you for this! I do think this should be native functionality of the module.
1

#88 User is offline   A.Miguel 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 12-October 11

Posted 11 July 2013 - 06:53 PM

Hi,

I have a critical problem here.

I managed to install the extension and configured it as explained in the tutorial. However I can't get the admins users having full access to the application:

   'components'=>array(
      'user'=>array(
         // enable cookie-based authentication
         'class' => 'auth.components.AuthWebUser',
         'allowAutoLogin'=>true,
      ),
      'authManager' => array(
         'class' => 'CDbAuthManager',
         'connectionID'=>'db',
         'behaviors' => array(
              array(
                  'class' => 'auth.components.AuthBehavior',
                  'admins' => array('admin'), // users with full access
                  ),
                ),
      ),


I then tried to login as 'admin' but I always get access denied. Enabling logging I can see the access verification for admin being done against the database authorization tables and I think it should bypass this process as it belongs to superuser list.

NOTE: admin is a valid username defined in User database table.


Any help?


Thanks
Miguel
0

#89 User is offline   Ahamed Rifaideen 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 380
  • Joined: 14-February 13
  • Location:chennai, tamilnadu

Posted 25 July 2013 - 06:04 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.

when i configure this module i got this error
Object configuration must be an array containing a "class" element.
here is my configuration
    'authManager' => array(

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

My Blog - Yii Learner
0

#90 User is offline   whatif 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 11-April 13

Posted 25 July 2013 - 07:51 AM

To correctly apply bootstrap theme ( yii-bootstrap-2.1.0.r355 ) to auth module ( yii-auth-1.6.0 ), I have to change the auth in config/main.php like below:

        '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' => 'username', // the name of the user name column.//my DB uses 'username' instead of 'name'
//            'appLayout' => 'application.views.layouts.main', // the layout used by the module.//not working
            'appLayout' => 'webroot.themes.bootstrap.views.layouts.main', // the layout used by the module.//good working
            'viewDir' => null, // the path to view files to use with this module.
        ),


0

#91 User is offline   kullar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 28-June 12

Posted 25 July 2013 - 02:00 PM

Is there a demo how to use it with authorization? How to add roles to user on authenitication?

I made Operations assignment.* and role.* and added these operations to admin user but when I try to access I get 401 error.
0

#92 User is offline   whatif 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 11-April 13

Posted 25 July 2013 - 06:37 PM

View PostAhamed Rifaideen, on 25 July 2013 - 06:04 AM, said:

when i configure this module i got this error
Object configuration must be an array containing a "class" element.
here is my configuration
    'authManager' => array(

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




Try this one:

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


0

#93 User is offline   whatif 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 11-April 13

Posted 25 July 2013 - 08:37 PM

Quote

if (!Yii::app()->user->isAdmin)

<== this part should be commented out to make the 'eye-open' link appear always in the right-most column of Assignments tab ( auth/widgets/AuthAssignmentColumn.php line 33 )

	/**
	 * Renders the data cell content.
	 * @param integer $row the row number (zero-based).
	 * @param mixed $data the data associated with the row.
	 */
	protected function renderDataCellContent($row, $data)
	{
//		if (!Yii::app()->user->isAdmin)
		{
			$this->grid->controller->widget('bootstrap.widgets.TbButton', array(
				'type' => 'link',
				'size' => 'mini',
				'icon' => 'eye-open',
				'url' => array('view', 'id' => $data->{$this->idColumn}),
				'htmlOptions' => array('rel' => 'tooltip', 'title' => Yii::t('AuthModule.main', 'View')),
			));
		}
	}

0

#94 User is offline   jmendez 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 10-August 13

Posted 10 August 2013 - 08:42 PM

Hello,,

I am newer with Yii and today I have installed the auth extension but when I want to access to /auth/assignment/index, /auth/role/index, ..., the application show me "Error 401 Access denied".

The problem is that "if ($user->isAdmin)" always return false. If I comment the above line and the extension works fine.

I have a rol "admin" in AuthItem and a user with this role in AuthAssignment.

	'import'=>array(
		'application.models.*',
		'application.components.*',
		'application.modules.auth.*',
		'application.modules.auth.components.*',
	),
	'theme'=>'bootstrap', // requires you to copy the theme under your themes directory
	'modules'=>array(
		// uncomment the following to enable the Gii tool
		
		'gii'=>array(
			'class'=>'system.gii.GiiModule',
			'password'=>'xxxx',
			// If removed, Gii defaults to localhost only. Edit carefully to taste.
			'ipFilters'=>array('127.0.0.1','::1'),
			'generatorPaths'=>array(
                		'bootstrap.gii',
			),
		),
		'auth' => array(
			'strictMode' => true, // when enabled authorization items cannot be assigned children of the same type.
			'userClass' => 'Usuario', // the name of the user model class.
			'userIdColumn' => 'id', // the name of the user id column.
			'userNameColumn' => 'email', // 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.
		),
	),
	// application components
	'components'=>array(
		'bootstrap'=>array(
			 'class'=>'bootstrap.components.Bootstrap',
		),
		'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
			'class' => 'auth.components.AuthWebUser',
		),
		// para gestionar la autenticación basada en roles con base de datos (db definido después en este mismo fichero)
		'authManager'=>array(
			'class'=>'CDbAuthManager',
			// 'class'=>'auth.components.CachedDbAuthManager',
			// 'cachingDuration'=>3600,
			'connectionID'=>'db',
			'behaviors' => array(
				'auth' => array(
					'class' => 'auth.components.AuthBehavior',
      					'admins' => array('admin'), // users with full access
				),
			),
		),


Thanks.
0

#95 User is offline   jmendez 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 10-August 13

Posted 11 August 2013 - 07:55 AM

View Postjmendez, on 10 August 2013 - 08:42 PM, said:

Hello,,

I am newer with Yii and today I have installed the auth extension but when I want to access to /auth/assignment/index, /auth/role/index, ..., the application show me "Error 401 Access denied".

The problem is that "if ($user->isAdmin)" always return false. If I comment the above line and the extension works fine.

I have a rol "admin" in AuthItem and a user with this role in AuthAssignment.

	'import'=>array(
		'application.models.*',
		'application.components.*',
		'application.modules.auth.*',
		'application.modules.auth.components.*',
	),
	'theme'=>'bootstrap', // requires you to copy the theme under your themes directory
	'modules'=>array(
		// uncomment the following to enable the Gii tool
		
		'gii'=>array(
			'class'=>'system.gii.GiiModule',
			'password'=>'xxxx',
			// If removed, Gii defaults to localhost only. Edit carefully to taste.
			'ipFilters'=>array('127.0.0.1','::1'),
			'generatorPaths'=>array(
                		'bootstrap.gii',
			),
		),
		'auth' => array(
			'strictMode' => true, // when enabled authorization items cannot be assigned children of the same type.
			'userClass' => 'Usuario', // the name of the user model class.
			'userIdColumn' => 'id', // the name of the user id column.
			'userNameColumn' => 'email', // 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.
		),
	),
	// application components
	'components'=>array(
		'bootstrap'=>array(
			 'class'=>'bootstrap.components.Bootstrap',
		),
		'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
			'class' => 'auth.components.AuthWebUser',
		),
		// para gestionar la autenticación basada en roles con base de datos (db definido después en este mismo fichero)
		'authManager'=>array(
			'class'=>'CDbAuthManager',
			// 'class'=>'auth.components.CachedDbAuthManager',
			// 'cachingDuration'=>3600,
			'connectionID'=>'db',
			'behaviors' => array(
				'auth' => array(
					'class' => 'auth.components.AuthBehavior',
      					'admins' => array('admin'), // users with full access
				),
			),
		),


Thanks.


At the moment, i have the next function in AuthWebUser.php

	public function getIsAdmin()
	{
		$auth=Yii::app()->authManager;
		if($auth->isAssigned("admin",Yii::app()->user->id)) {
			return true;
		}
			
		return $this->getState('__isAdmin', false);
	}


If someone has the right solution, please help me.

Thanks.
0

#96 User is offline   whatif 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 11-April 13

Posted 11 August 2013 - 06:22 PM

View Postjmendez, on 11 August 2013 - 07:55 AM, said:

At the moment, i have the next function in AuthWebUser.php

	public function getIsAdmin()
	{
		$auth=Yii::app()->authManager;
		if($auth->isAssigned("admin",Yii::app()->user->id)) {
			return true;
		}
			
		return $this->getState('__isAdmin', false);
	}


If someone has the right solution, please help me.


Thanks.



@jmendez
This problem has been solved.
See my comments in Auth extension page.

http://www.yiiframew...extension/auth/

#14354report it00
whatif at 2013/08/05 10:54pm
How to fix ' "AuthWebUser.admins" is not defined.'

You do not need to change getIsAdmin() in AuthWebUser.php. Instead you should change the config/main.php as in my comment. Please check which version of Auth you are using and set the right config/main.php accordingly.

Cheers.
0

#97 User is offline   jmendez 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 10-August 13

Posted 12 August 2013 - 03:10 PM

View Postwhatif, on 11 August 2013 - 06:22 PM, said:

@jmendez
This problem has been solved.
See my comments in Auth extension page.

http://www.yiiframew...extension/auth/

#14354report it00
whatif at 2013/08/05 10:54pm
How to fix ' "AuthWebUser.admins" is not defined.'

You do not need to change getIsAdmin() in AuthWebUser.php. Instead you should change the config/main.php as in my comment. Please check which version of Auth you are using and set the right config/main.php accordingly.

Cheers.


Hello @whatif,

I have the yii-auth-1.6.0 version downloaded from the extension site. My currently configuration is

'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
			'class' => 'auth.components.AuthWebUser',
		),
		// para gestionar la autenticación basada en roles con base de datos (db definido después en este mismo fichero)
		'authManager'=>array(
				'class'=>'CDbAuthManager',
				// 'class'=>'auth.components.CachedDbAuthManager',
  				// 'cachingDuration'=>3600,
				'connectionID'=>'db',
				'behaviors' => array(
			    	'auth' => array(
						'class' => 'auth.components.AuthBehavior',
      					'admins' => array('admin'), // users with full access
					),
			      ),
		),


and I think It likes your configuration, but if I don't change getIsAdmin() I couldn't access to /auth/assignment/index.html.

Could you tell me where the problem is?

Thanks
0

#98 User is offline   whatif 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 11-April 13

Posted 13 August 2013 - 07:39 PM

View Postjmendez, on 12 August 2013 - 03:10 PM, said:

Hello @whatif,

I have the yii-auth-1.6.0 version downloaded from the extension site. My currently configuration is

'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
			'class' => 'auth.components.AuthWebUser',
		),
		// para gestionar la autenticación basada en roles con base de datos (db definido después en este mismo fichero)
		'authManager'=>array(
				'class'=>'CDbAuthManager',
				// 'class'=>'auth.components.CachedDbAuthManager',
  				// 'cachingDuration'=>3600,
				'connectionID'=>'db',
				'behaviors' => array(
			    	'auth' => array(
						'class' => 'auth.components.AuthBehavior',
      					'admins' => array('admin'), // users with full access
					),
			      ),
		),


and I think It likes your configuration, but if I don't change getIsAdmin() I couldn't access to /auth/assignment/index.html.

Could you tell me where the problem is?

Thanks


Hi @jmendez

1. I think you made a typo.

You cannot directly access the file as in '/auth/assignment/index.html'.

Instead, you can access the auth page with this route /auth/assignment/index

2.
If you cannot still access this route /auth/assignment/index, then check if you have registered your user name as an administrator.
For example if your username is "your_username", this should be added to the array like below:
              'authManager'=>array(
				'class'=>'CDbAuthManager',
				// 'class'=>'auth.components.CachedDbAuthManager',
  				// 'cachingDuration'=>3600,
				'connectionID'=>'db',
				'behaviors' => array(
			    	        'auth' => array(
						'class' => 'auth.components.AuthBehavior',
      					'admins' => array('admin', 'your_username' ), // users with full access
					),
			      ),
		),


Hope this helps
0

#99 User is offline   jmendez 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 10-August 13

Posted 14 August 2013 - 02:45 AM

Hello @whatif,

I thought that "admins" contains the roles with full access but as you said "admins" contains the usernames with full access.

I work with roles. Is it possible define the admin role in the config file?

At the moment I have change the validation method but I am sure It is not the right solution.

Thanks.

View Postwhatif, on 13 August 2013 - 07:39 PM, said:

Hi @jmendez

1. I think you made a typo.

You cannot directly access the file as in '/auth/assignment/index.html'.

Instead, you can access the auth page with this route /auth/assignment/index

2.
If you cannot still access this route /auth/assignment/index, then check if you have registered your user name as an administrator.
For example if your username is "your_username", this should be added to the array like below:
              'authManager'=>array(
				'class'=>'CDbAuthManager',
				// 'class'=>'auth.components.CachedDbAuthManager',
  				// 'cachingDuration'=>3600,
				'connectionID'=>'db',
				'behaviors' => array(
			    	        'auth' => array(
						'class' => 'auth.components.AuthBehavior',
      					'admins' => array('admin', 'your_username' ), // users with full access
					),
			      ),
		),


Hope this helps

0

#100 User is offline   Andra 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 25-November 11
  • Location:Indonesia

Posted 01 September 2013 - 01:34 PM

I am new in this module.. but i hope all of you want to help me.
Why i can not access create page for all controller (Roles, Task, Operations)
When i click add button, it show list page. not create page. if i see the url it show the right url (http://webapp/auth/role/create

anyone can help me..? :mellow:
0

Share this topic:


  • (7 Pages)
  • +
  • « First
  • 3
  • 4
  • 5
  • 6
  • 7
  • 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