[EXTENSION] srbac : Web interface for the administration of rbac

hey,dear spyros,good job.

but i have a question.

i use yii1.1 and srbac 1.1,when i installed finished,i open http://localhost/srbac/authitem/frontpage

,it will guide me to http://localhost/srbac/authitem/install

and i can only install,and install again…

what’s the problem? is i finished yet??

thank you

I have installed srbac 1.1 ,however, it reports : There is an error in your configuration

but I can not find out where is the wrong or missing config, it would be better to point which configuration item is wrong .

another question:

Did I need to establish 3 following tables firstly for AuthManager:

items, assignments, itemchildren

which colums are required by these tables then?

looking forward your kindly answer,

thank you,

What database are you using?

Are the auth tables created?

is http://localhost/srbac/authitem/manage working?

The database tables are created by srbac.You don’t have to create them.

When in install page are any srbac attributes painted red instead of black or green?

Could you paste here your srbac configuration?

em,I am meeting the same problem as you.

your demo url can’t be reached now ,can it?

no ,when i visit http://localhost/srbac/authitem/manage,it will turn to install page.

well,i guess i will happen when it’s a new fresh installation of yii.

1,first create webapp

2,create user table,and use "yiic shell" to "model user,crud user"…

3,unzip srbac to webapp’s module folder.

4,in config/main.php write the things.

5,open the url http://localhost/srbac, and install…

6,it mentions succesfully ,and I open http://localhost/srbac/manage,it will redirect to http://localhost/srbac/install again.

the main.php is:


'modules'=>array(

		'srbac'=>

			array(

			// Your application's user class (default: User)

			"userclass"=>"user",

			// Your users' table user_id column (default: userid)

			"userid"=>"userid",

			// your users' table username column (default: username)

			"username"=>"username",

			// If in debug mode (default: false)

			// In debug mode every user (even guest) can admin srbac, also 

			//if you use internationalization untranslated words/phrases 

			//will be marked with a red star

			"debug"=>true,

			// The number of items shown in each page (default:15)

			"pageSize"=>16,

			// The name of the super user

			"superUser" =>"Authority",

			//The css file to use

			//"css"=>"srbac_red.css", // must be in srbac css folder

			//The layout to use

			"layout"=>"application.views.layouts.main",

			//The not authorized page

			"notAuthorizedView"=>"application.views.site.login",

			// The always allowed actions

			"alwaysAllowed"=>array(

				'SiteLogin','SiteLogout','SiteIndex','SiteAdmin',

				'SiteError', 'SiteContact','SiteCaptcha'

			),

			// The operationa assigned to users

			"userActions"=>array(

				"Show","View","List"

			),

			// The number of lines of the listboxes

			"listBoxNumberOfLines" => 10,

			// The path to the custom images relative to basePath (default the srbac images path)

			//"imagesPath"=>"../images",

			//The icons pack to use (noia, tango)

			"imagesPack"=>"tango",

			// Whether to show text next to the menu icons (default false)

			"iconText"=>true,

		)

	),



and the auth section is:



[quote]
'authManager'=>array(

			// The type of Manager (Database)

			'class'=>'CDbAuthManager',

			// The database connection used

			'connectionID'=>'db',

			// The itemTable name (default:authitem)

			'itemTable'=>'AuthItem',

			// The assignmentTable name (default:authassignment)

			'assignmentTable'=>'AuthAssignment',

			// The itemChildTable name (default:authitemchild)

			'itemChildTable'=>'AuthItemChild',

		),
[/quote]


the installation info as following:

Your Database, AuthManager and srbac settings: 1.1

Database

Driver mysql

Connection mysql:host=127.0.0.1;dbname=rbac

AuthManager

Item Table AuthItem

Assignment Table AuthAssignment

Item child table AuthItemChild

srbac

yiiSupportedVersion

1.1.0

version

1.1.0 beta

debug

1

pageSize

16

alwaysAllowed

SiteLogin, SiteLogout, SiteIndex, SiteAdmin, SiteError, SiteContact, SiteCaptcha

userActions

Show, View, List

listBoxNumberOfLines

10

iconText

1

showHeader

showFooter

useAlwaysAllowedGui

userid

userid

username

username

userclass

user

superUser

Authority

css

srbac.css

notAuthorizedView

application.views.site.login

layout

application.views.layouts.main

imagesPath

srbac.images

imagesPack

tango

header

srbac.views.authitem.header

footer

srbac.views.authitem.footer

Yii

Yii version : 1.1b

Create demo authItems?

yep. and hope spyros can fix it…thank you spyros

I found in srbac :

models are all classes extends CActiveRecord,and the names exactly are:

Assignments, AuthItem and ItemChildren.

they are different from the configuration’s default,maybe it cause some wrong?

well, there isn’t any red attributes in the install list, I snapped it as attachments,and the exactly configuration is :

‘modules’=>array(

	'srbac' => array( 


		 'userclass'=>'User', 


		 'userid'=>'id', 


		 'username'=>'username', 


		 'debug'=>true, 


		 'pageSize'=>10, 


		 'superUser' =>'Authority', 


		 'css'=>'srbac_red.css',  


		 'layout'=>'application.views.layouts.admin', 


		 'notAuthorizedView'=>'application.views.site.unauthorized', 


		 'alwaysAllowed'=>array( 


			'SiteLogin','SiteLogout','SiteIndex','SiteAdmin','SiteError','SiteContact'), 


		 'userActions'=>array( 


			'Show','View','List'), 


		 'listBoxNumberOfLines' => 15, 


		 'useAlwaysAllowedGui'=>true,


		 'imagesPath' =>"http://localhost/Belief/protected/modules/srbac/images", 


		 'imagesPack'=>'noia', 


		 'iconText'=>true, 


		 'header'=>'application.views.header', 


		 'footer'=>'application.views.footer', 


		 'showHeader'=>true, 


		 'showFooter'=>true, 


	   ), 


  ),

			//authManager


			'authManager'=>array( 


				// The type of Manager (Database) 


				'class'=>'CDbAuthManager', 


				// The database component used 


				'connectionID'=>'db', 


				// The itemTable name (default:authitem) 


				'itemTable'=>'authitem', 


				// The assignmentTable name (default:authassignment) 


				'assignmentTable'=>'assignments', 


				// The itemChildTable name (default:authitemchild) 


				'itemChildTable'=>'itemchildren', 


			 ),

and mysql works well:

			'db'=>array(					


				'class'=>'CDbConnection',


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


				'username'=>'sys2009',


				'password'=>'mypwd',		


				'charset'=>'utf8',			


			),

//authManager

‘authManager’=>array(

// The type of Manager (Database)

‘class’=>‘CDbAuthManager’,

// The database component used

‘connectionID’=>‘db’,

// The itemTable name (default:authitem)

‘itemTable’=>‘authitem’,

// The assignmentTable name (default:authassignment)

‘assignmentTable’=>‘assignments’,

// The itemChildTable name (default:authitemchild)

‘itemChildTable’=>‘itemchildren’,

),

change Authitem to authitem

change Assignments to assignments

change Itemchildren to itemchildren

and it works .wow.~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hi Spyros,

Just wondering if you can clarify a couple of things for me. How does alwaysAllowed GUI interface work? I noticed there is an empty array in allowed.php under components directory.

At the moment when I press save nothing is actually saved. Do I need to add controller actions to allowed.php array?

Also, in config file what does the ‘userActions’=>array(‘Show’,‘View’,‘List’) specify?

Look forward to your reply… thanks :huh:

===================

wow, My srbac is working now.

I have found out the source causing all of the matters:

  1. css should be corrected—then it can show you where is wrong in red:

  2. other configurations:

===============================

‘db’=>array(

				'class'=>'CDbConnection',<------shouldn't be changed


				'connectionString'=>'mysql:host=localhost;dbname=testdb',<------should be change according to yours


				'username'=>'sys2009',<------should be change according to yours


				'password'=>'mypwd',	<------should be change according to yours	


				'charset'=>'utf8',	<------should be change according to yours		


			),

=======================================================

			//authManager


			'authManager'=>array( 


				// The type of Manager (Database) 


				'class'=>'CDbAuthManager', <------shouldn't be changed


				// The database component used 


				'connectionID'=>'db', <------shouldn't be changed


				// The itemTable name (default:authitem) 


				'itemTable'=>'authitem', <------shouldn be corrected as this


				// The assignmentTable name (default:authassignment) 


				'assignmentTable'=>'assignments', <------shouldn be corrected as this


				// The itemChildTable name (default:authitemchild) 


				'itemChildTable'=>'itemchildren', <------shouldn be corrected as this				 ),


),

======================================

‘modules’=>array(

	'srbac' => array( 


		 'userclass'=>'User', <------should be change according to yours


		 'userid'=>'id', <------should be change according to yours


		 'username'=>'username', <------should be change according to yours


		 'debug'=>true, 


		 'pageSize'=>10, 


		 'superUser' =>'Authority', 


		 'css'=>'srbac.css', <<<------shouldn be corrected as this!!!!


		 'layout'=>'application.views.layouts.main', <------shouldn't be changed


           'notAuthorizedView'=>'application.views.site.login', <------shouldn't be changed			 


		 'alwaysAllowed'=>array( 				'SiteLogin','SiteLogout','SiteIndex','SiteAdmin','SiteError','SiteContact','SiteCaptcha'), 


		 'userActions'=>array( 


			'Show','View','List'), 


		 'listBoxNumberOfLines' => 15, 


		 'useAlwaysAllowedGui'=>true,<------shouldn't be changed			 


		 'imagesPath' =>"srbac.images", <------shouldn't be changed


		 'imagesPack'=>'tango', 


		 'iconText'=>true, 


		 'header'=>'srbac.views.authitem.header', <------shouldn't be changed


		 'footer'=>'srbac.views.authitem.footer', <------shouldn't be changed


		 'showHeader'=>true, 


		 'showFooter'=>true, 


	   ), 


	   'import'=>array( 


'application.modules.srbac.controllers.SBaseController', 

),

well ,I find out where the problem arises: ‘css’=>‘srbac.css’, <------here I am too strictly to follow the srbac_guide which was: ‘css’=>‘srbac_red.css’,

and I can find out which is red now

=================

the srbac_guide_1.1 should be corrected ,thank you.


hey ,guy : mine srbac is working now.

‘useAlwaysAllowedGui’=>true,<----

will let it work.


‘userActions’=>array(

			'Show','View','List'), 

you needn’t change it.

be careful with css:

following is mine config------------- srbac_guide can’t be use immediately

		 'debug'=&gt;true, 


		 'pageSize'=&gt;10, 


		 'superUser' =&gt;'Authority', 


		 'css'=&gt;'srbac.css',  


		 'layout'=&gt;'application.views.layouts.main', 


		 'notAuthorizedView'=&gt;'application.views.site.login', 


		 'alwaysAllowed'=&gt;array( 


			'SiteLogin','SiteLogout','SiteIndex','SiteAdmin','SiteError','SiteContact','SiteCaptcha'), 


		 'userActions'=&gt;array( 


			'Show','View','List'), 


		 'listBoxNumberOfLines' =&gt; 15, 


		 'useAlwaysAllowedGui'=&gt;true,


		 'imagesPath' =&gt;&quot;srbac.images&quot;, 


		 'imagesPack'=&gt;'tango', 


		 'iconText'=&gt;true, 


		 'header'=&gt;'srbac.views.authitem.header', 


		 'footer'=&gt;'srbac.views.authitem.footer', 


		 'showHeader'=&gt;true, 


		 'showFooter'=&gt;true, 

=======================

good lucky

========================

well, if you have installed demo, you’d better install it again without demo.

then you can find out what should to do.

there is a lot of work to do ,isn’t it?

thanks to cihappy2’s configuration sample, it corrects mine and makes my srbac work

Thanks for you reply sys2009. However, what i’m wondering is how the alwaysAllowed GUI interface works? I can define my alwaysAllowed actions in my config no problem, which I can do, although I would like to try and figure out what im doing wrong.

This is my config…




				   'srbac' => array( 

				     'userclass'=>'User', 

				     'userid'=>'id', 

				     'username'=>'username', 

				     'debug'=>true, 

				     'pageSize'=>10, 

				     'superUser' =>'Authority', 

				     'css'=>'srbac.css',  

				     'layout'=>'application.views.layouts.main', 

				     'notAuthorizedView'=>'application.views.site.unauthorized', 

					 'alwaysAllowed'=>'gui',

					 'userActions'=>array('Show','View','List'),

					 'listBoxNumberOfLines' => 15,

					 'useAlwaysAllowedGui'=>true,

				     'imagesPath' => 'application.modules.admin.modules.srbac.images', 

				     'imagesPack'=>'tango',

					 'iconText'=>true,

					 'header'=>'srbac.views.authitem.header',

					 'footer'=>'srbac.views.authitem.footer',

					 'showHeader'=>true,

					 'showFooter'=>true 

						),



the latest work is following the srbac_guide to assign.

Hey Spyros,

I’m gathering that using the alwaysAllowed GUI interface saves/removes/updates preferences to the array in allowed.php

Can you confirm this as it is not currently working for me. Everything else is working great though.

thanks

Yes, having capital letters in database table names is no good thing ;)

The database will save the names in lower case and srbac will think that the tables are not created