Yii Framework Forum: Chapter 8 – RBAC - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Chapter 8 – RBAC Some hints about this chapter.

#1 User is offline   Cálcio 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 84
  • Joined: 18-January 11
  • Location:Niterói - RJ - Brazil

Posted 17 February 2012 - 07:23 AM

This chapter confuses many people and I was one this person. Read some hints (here in this subforum) and make several tests, I finaly made it works.

I'll try explain it with code blocks. Keep in mind that I made these tests using Ubuntu 10.04.

Step #1 – Pg 179 - Configuring the authorization manager
Here we need to configure our protected/config/main.php, however I thought this part is confuse. Where I put the code suggested? I will show where we must put it.

Open the file trackstar/protected/config/main.php. (I'll show a piece of code)

<?php
// uncomment the following to define a path alias 
// Yii::setPathOfAlias('local','path/to/local-folder'); 

// This is the main Web application configuration. Any writable 
// CWebApplication properties can be configured here. 
return array(
	
	Begin of File

	// application components 
	'components'=>array( 
		'user'=>array( 
			// enable cookie-based authentication 
			'allowAutoLogin'=>true, 
		), 
		// uncomment the following to enable URLs in path-format		 
		'urlManager'=>array( 
			'urlFormat'=>'path', 
			'showScriptName' => false, 
			'urlSuffix' => '.html', 
			'rules'=>array( 
				'<controller:\w+>/<id:\d+>'=>'<controller>/view', 
				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', 
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>', 
			), 
		),
		// uncomment the following to use a MySQL database		 
		'db'=>array( 
			'connectionString' => 'mysql:host=localhost;dbname=trackstar_dev', 
			'emulatePrepare' => true, 
			'username' => 'root', 
			'password' => 'xxxxxxx', 
			'charset' => 'utf8', 
		), 
		 
		//Here we must put the code suggested.
		//This code is under components array()
		'authManager'=>array( 
           			 'class'=>'CDbAuthManager', 
           			 'connectionID'=>'db', 
      		 ),
	…

	),

	…
	
	End of file
);
?>

0

#2 User is offline   Cálcio 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 84
  • Joined: 18-January 11
  • Location:Niterói - RJ - Brazil

Posted 17 February 2012 - 07:24 AM

Step #2 – Pg 183 - Writing a console application command
We need to create a file RbacCommand.php in /protected/commands/shell/ . The first method of this class it's not necessary (for me it didn't work). So, remove it.

public function getHelp()
{
return <<<EOD
USAGE
rbac
DESCRIPTION
This command generates an initial RBAC authorization hierarchy.
EOD;
}

This part must be removed.

Step #3 – Pg 186 – (runing the command)
Access the folder trackstar (I use GNU/Linux) so: /var/www/trackstar. <enter>.
On the prompt type, protected/yiic shell protected/config/main.php. You should see something like it:

Yii Interactive Tool v1.1 (based on Yii v1.1.2)
Please type 'help' for help. Type 'exit' to quit.
>>

Now type help to see a list of available commands:
>> help

At the prompt, you may enter a PHP statement or one of the following
commands:
- controller
- crud
- form
- help
- model
- module
- rbac

If you see the command rbac in the list. It's evereting ok. So run the command.

>> rbac

You will see it:

This command will create three roles: Owner, Member, and Reader and the
following premissions:
create, read, update and delete user
create, read, update and delete project
create, read, update and delete issue
Would you like to continue? [Yes|No] Yes
Authorization hierarchy successfully generated.

type “Yes” after run the command type “exit”.

I realy hope that it, help you with this topic.
Credits for the topics from @hman and @windsor. Sorry if I forgot someone.

Excuse my bad English.
0

#3 User is offline   José Dávalos Rosas 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 04-September 11
  • Location:Sonora, México

Posted 11 April 2012 - 04:03 PM

Thanks for the info, i was running into the same problem
0

#4 User is offline   Lamis 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 19-April 12

Posted 21 April 2012 - 06:48 AM

Thank You!
0

#5 User is offline   Ahamed Rifaideen 

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

Posted 22 February 2013 - 07:35 AM

Yeah thanks dear.. I cannot understand about why we are creating associateUserToRole() and removeUserFromRole() where we are using there methods there are too confusing me please help..
My Blog - Yii Learner
0

#6 User is offline   Ahamed Rifaideen 

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

Posted 22 February 2013 - 07:40 AM

Please explain about this topic rbac i understand about authorization hierarchy.. But there chapter confuses me very much Please expand this thread upto the end of rbac given in agile web application development
My Blog - Yii Learner
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

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