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

Jump to content

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

#61 User is offline   cappadochian 

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

Posted 12 April 2013 - 01:05 PM

View Postcodesutra, on 12 April 2013 - 12:59 PM, said:

Thanks cappadochian for your quick responses. But finally i manage to resolve all that errors :)

thanks again. :)

and what was the problem?
0

#62 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 12 April 2013 - 01:12 PM

View Postcappadochian, on 12 April 2013 - 01:05 PM, said:

and what was the problem?


Well there was a two problem in my case.
1.Exception for AuthWebuser Class.:- i have fixed it by checking a component class alias.
2.Permission access issue :- Well actually admins array values are not present in the database and i was logged with the other user.That is why that error was occurring.So i have just define the default admins in database too which can access the Auth management. :)
CodeSutra
0

#63 User is offline   almix 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 23-September 11

Posted 12 April 2013 - 02:22 PM

codesutra, please explain more fully. I can't understand what did you do to solve the problem.

cappadochian, thank you, but you settings to main.php didn't help me.

And another error - CWebApplication and its behaviors do not have a method or closure named "getLanguages".
Think something wrong with Bootstrap. There is "$languages = Yii::app()->getLanguages();" but in main.php I have no 'getLanguages'. Did you make it work with bootstrap?

SOLVED! - Just dont use components/LanguageMenu.php and turn off it in views/layouts/main.php

This post has been edited by almix: 13 April 2013 - 01:38 AM

0

#64 User is offline   almix 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 23-September 11

Posted 13 April 2013 - 01:39 AM

Chris, what's difference between 'yiistrap' and 'yii-bootstrap' extensions? Why do you become use yiistrap?

And what's best - use CPhpAuthManager or use CDbAuthManager?
0

#65 User is offline   GAdam 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 02-January 12

Posted 13 April 2013 - 07:29 AM

With the new version (1.6.0) I have a problem.

Property "AuthWebUser.admins" is not defined.

With version 1.4.1 everything is fine (with same config).
0

#66 User is offline   Adam I 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 07-April 13

Posted 14 April 2013 - 07:04 AM

View PostChris83, on 08 April 2013 - 05:15 PM, said:

You're not forced to use bootstrap, just write your own views and you can use whatever you want. You can configure the views folder for the module.


Hi Chris,

I've modified the view files to function without requiring bootstrap. In addition to the view files, I also had to modify a number of the files in the "widgets" directory, as they also used bootstrap-specific widgets.

Do you think others would be interested in a "strapless" version of auth? I'm happy to provide my changes if you would like to include them as an alternate set of view/widget files.
0

#67 User is offline   almix 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 23-September 11

Posted 17 April 2013 - 03:58 AM

Does anybody know how to automatically assign role "Authenticated" when user registers himself, as it was in Rights?

Chris, in Rights you declare in RightsModule
/**
	* @property string the name of the guest role.
	*/
	public $authenticatedName = 'Authenticated';  



and we could use, for example, in modules/user/AdminController line: Rights::assign($authenticatedName, $model->id);

public function actionCreate()
	{
		$model=new User;
		$profile=new Profile;
		$this->performAjaxValidation(array($model,$profile));
		if(isset($_POST['User']))
		{
			$model->attributes=$_POST['User'];
			$model->activkey=Yii::app()->controller->module->encrypting(microtime().$model->password);
			$profile->attributes=$_POST['Profile'];
			$profile->user_id=0;
			if($model->validate()&&$profile->validate()) {
				$model->password=Yii::app()->controller->module->encrypting($model->password);
				if($model->save()) {
					$profile->user_id=$model->id;
					$profile->save();
				// assign user the 'Authenticated' role for Rights module
					$authenticatedName = Rights::module()->authenticatedName;
					Rights::assign($authenticatedName, $model->id);
				}
				$this->redirect(array('view','id'=>$model->id));
			} else $profile->validate();
		}

		$this->render('create',array(
			'model'=>$model,
			'profile'=>$profile,
		));
	}  


using method assign from modules/rights/components/Rights.php:

public static function assign($itemName, $userId, $bizRule=null, $data=null)
	{
		$authorizer = self::getAuthorizer();
		return $authorizer->authManager->assign($itemName, $userId, $bizRule, $data);
	}  

1

#68 User is offline   jpj 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 75
  • Joined: 27-October 10

Posted 18 April 2013 - 05:15 AM

I know it's easy to change but why isn't it possible to choose a role as a child of another role ?
Also, why isn't it possible to manage bizrule/data columns ? Is it for security concerns ?
0

#69 User is offline   almix 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 23-September 11

Posted 20 April 2013 - 11:45 AM

View Postjpj, on 18 April 2013 - 05:15 AM, said:

I know it's easy to change but why isn't it possible to choose a role as a child of another role ?
Also, why isn't it possible to manage bizrule/data columns ? Is it for security concerns ?


Just set strictMode to false for choosing role as a child:

'modules' => array(
'auth' => array(
'strictMode' => false, // when enabled authorization items cannot be assigned children of the same type.
'userClass' => 'Users',
1

#70 User is offline   jpj 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 75
  • Joined: 27-October 10

Posted 20 April 2013 - 12:13 PM

Ok thanks.

I don't want to use bizrule in db + eval.
In our apps, we need to store that a given user has a given permission over 1 or n specific records of any given table.
Something like that, just for instance:
user1 can edit posts 1,34,45
user2 can edit any post
user3 can edit posts 3,34,56
user3 can edit comments 2,45,46

Do you think we can achieve that with the extension without using bizrule+data column ?
0

#71 User is offline   almix 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 23-September 11

Posted 20 April 2013 - 12:33 PM

View Postjpj, on 20 April 2013 - 12:13 PM, said:

Ok thanks.

I don't want to use bizrule in db + eval.
In our apps, we need to store that a given user has a given permission over 1 or n specific records of any given table.
Something like that, just for instance:
user1 can edit posts 1,34,45
user2 can edit any post
user3 can edit posts 3,34,56
user3 can edit comments 2,45,46

Do you think we can achieve that with the extension without using bizrule+data column ?


jpj, i use this auth - https://github.com/kakousis/yii-auth. It's with bizrule, but not up to date. you need setup it yourself with last release of Chris.
0

#72 User is offline   jpj 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 75
  • Joined: 27-October 10

Posted 20 April 2013 - 01:21 PM

It's with OR without bizrule ? Because I try to avoid bizrule. Not secure.
It seems to me the link you gave leads to yii auth extension, classic one.
0

#73 User is offline   almix 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 23-September 11

Posted 20 April 2013 - 02:07 PM

View Postjpj, on 20 April 2013 - 01:21 PM, said:

It's with OR without bizrule ? Because I try to avoid bizrule. Not secure.
It seems to me the link you gave leads to yii auth extension, classic one.


Chris's Auth doesn't have bizrule field in backend. And https://github.com/kakousis/yii-auth has. Or what do you need. What code is unsecure?
0

#74 User is offline   jpj 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 75
  • Joined: 27-October 10

Posted 20 April 2013 - 02:35 PM

I need to manage something like the example I gave but without bizrule. It's not serious to store PHP code in DB and process it with eval, even more for auth management.

Maybe I'll do this:

Store in authAssignment.data a serialized array storing all the records ID associated with the authitem assigned.
I create a class that inherits CdbAuthManager to override checkAccess or I create another method to check the access, that doesn't call evaluateBizrule() so it's more secure, and it will perform the job the function I would have called in the bizrule would have done !

In case I do that, I'll extend the extension: when creating an assignment, it'll be possible to choose a table of the db, then it'll be possible to choose 1 or more records of the chosen table. Their ID will be stored in authAssignment.data in a serialized array.
0

#75 User is offline   Hasan Tokatlı 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 23-February 13

Posted 21 April 2013 - 02:42 AM

View Postjpj, on 20 April 2013 - 02:35 PM, said:

I need to manage something like the example I gave but without bizrule. It's not serious to store PHP code in DB and process it with eval, even more for auth management.

Maybe I'll do this:

Store in authAssignment.data a serialized array storing all the records ID associated with the authitem assigned.
I create a class that inherits CdbAuthManager to override checkAccess or I create another method to check the access, that doesn't call evaluateBizrule() so it's more secure, and it will perform the job the function I would have called in the bizrule would have done !

In case I do that, I'll extend the extension: when creating an assignment, it'll be possible to choose a table of the db, then it'll be possible to choose 1 or more records of the chosen table. Their ID will be stored in authAssignment.data in a serialized array.


Thanks jpj, i was thinking about the same problem. Your idea is suitable in my opinion.
0

#76 User is offline   Hasan Tokatlı 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 23-February 13

Posted 21 April 2013 - 02:45 AM

View PostGAdam, on 13 April 2013 - 07:29 AM, said:

With the new version (1.6.0) I have a problem.

Property "AuthWebUser.admins" is not defined.

With version 1.4.1 everything is fine (with same config).


Hi GAdam,
please paste your related configs here if the problem goes on.
0

#77 User is offline   jpj 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 75
  • Joined: 27-October 10

Posted 23 April 2013 - 10:16 AM

My question is not really about the extension: I've noticed that in your views, at the top of the files, you have a declaration of the vars used in the view, for example:
/* @var $this AssignmentController */
/* @var $model User */
/* @var $authItemDp AuthItemDataProvider */
/* @var $formModel AddAuthItemForm */
/* @var $form TbActiveForm */
/* @var $assignmentOptions array */


You write it manually or there's a way to generate that ?
Thanks !
0

#78 User is offline   toph 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 21-June 11

Posted 28 April 2013 - 04:14 PM

View PostChris83, on 07 April 2013 - 02:16 PM, said:

I recently added support for moduleId.*, try upgrading and report back. I hope this resolves your issue.

It did. Thanks.
0

#79 User is offline   chopin2256 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 02-May 13

Posted 02 May 2013 - 01:48 PM

One problem I am having with these RBAC modules is that there isn't a user search. I find this to be a problem especially when a website grows very large, and you must search for a member in order to grant specific permissions.

Do you think you can add search/filter functionality in the next update?
0

#80 User is offline   tempelfeld 

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

Posted 12 May 2013 - 12:19 PM

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

By comments:
http://www.yiiframew...on/auth/#c12898
http://www.yiiframew...on/auth/#c12067
http://www.yiiframew...on/auth/#c12065


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



Does anyone know of correct method to do this?

Best regards.
0

Share this topic:


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