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

Hello,

I am getting this error

in main.php




	'import'=>array(

		'application.models.*',

		'application.components.*',

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

	),

	// AuthConfig

	'authManager'=>array(

	// The type of Manager (Database)

	'class'=>'CDbAuthManager',

	// The database component used

	'connectionID'=>'db',

	// The itemTable name (default:authitem)

	'itemTable'=>'items',

	// The assignmentTable name (default:authassignment)

	'assignmentTable'=>'assignments',

	// The itemChildTable name (default:authitemchild)

	'itemChildTable'=>'itemchildren',

	),

'modules'=>array(	

		'srbac' => array(

		'userclass'=>'User', //optional defaults to User

		'userid'=>'user_ID', //optional defaults to userid

		'username'=>'username', //optional defaults to username

		'debug'=>true, //optional defaults to false

		'pageSize'=>10, //optional defaults to 15

		'superUser' =>'Authority', //optional defaults to Authorizer

		'css'=>'srbac.css', //optional defaults to srbac.css

		'layout'=>

		'application.views.layouts.admin', //optional defaults to empty string

		// must be an existing alias

		'notAuthorizedView'=>

		'srbac.views.authitem.unauthorized ', // optional defaults to

		//srbac.views.authitem.unauthorized, must be an existing alias

		'alwaysAllowed'=>array( //optional defaults to gui

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

		'SiteError', 'SiteContact'),

		),

),



Not Sure what is going on. Thanks for any help

i uploaded all of the files to /protected/modules/* , i had to create the directory, not sure if thats the correct location, it may be my problem

As i found out my problem, now I have found another one. I left out an array in the main.php


'components'=>array(

		'user'=>array(

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

			'authManager'=>array(

	// The type of Manager (Database)

	'class'=>'CDbAuthManager',

	// The database component used

	'connectionID'=>'db',

	// The itemTable name (default:authitem)

	'itemTable'=>'items',

	// The assignmentTable name (default:authassignment)

	'assignmentTable'=>'assignments',

	// The itemChildTable name (default:authitemchild)

	'itemChildTable'=>'itemchildren',

	),

Now I have this problem

As I can see you have your AuthManager config array inside user’s array

should be




<?php

'components'=>array(

     'user'=>array(

        // enable cookie-based authentication

       'allowAutoLogin'=>true,

     },

     'authManager'=>array(

        // The type of Manager (Database)

        'class'=>'CDbAuthManager',

        // The database component used

        'connectionID'=>'db',

        // The itemTable name (default:authitem)

        'itemTable'=>'items',

        // The assignmentTable name (default:authassignment)

        'assignmentTable'=>'assignments',

        // The itemChildTable name (default:authitemchild)

        'itemChildTable'=>'itemchildren',

        ),

     }

?>



Also in srbac layout attribute should point to an existing file, set it to "application.views.layouts.main"

Thank you, I am making progess with it. Now I just need to get the pdo driver.

Hi guys!

Is it possible somehow to automatically assign, let’s say, User role to all registered users?

Thank you!

you have to enable pdo in your php.ini file

You can assign the user role to the user when he is creating his account so it will be saved in the db and whenever he logs in whe will have this role

this is a good point to me either:

"You can assign the user role to the user when he is creating his account so it will be saved in the db and whenever he logs in whe will have this role"

could you please provide a sample showing how to perform this by using srbac actions? I mean, is it possible to perform any srbac controller/action to assign some role to a registered user or should I do it via SQL?

thanks

You can do it by coding




<?php

 $auth = Yii::app()->authManager;

 $auth->assign("User Role", $userid, $bizRules ,$data);

 ?>



thats great!!! got it…srbac uses CAuthManager :)

thank you very much, Spyros!!!

Hi there,

I ran into some problems with srbac: it can’t handle controller and action names with two Capital letters in its name like in


ListItemController, actionHistoryList

etc.

Srbac writes correct names (with two capitals) into DB tables (itemchildren) but gives an error on execution:

[html]Error:403 ‘You are not authorized for this action’[/html] on all two-capital letter items

I think I understand where it comes from: yii app itself returns controller/action in lower case then srbac capitalizes the first letter of each and compares against DB. And at this point it fails.

I see two possible solutions here

  1. modify the way srbac writes ControllerAction combo into the DB table - wrap it in ucfirst function

  2. create an AfterFind rule for itemchildren table that formats it consistently as [C]ontroller[A]ction. Unfortunately, it is not easy because I have a mix of Controller/Action names with 1-2 capitals

For the record I am using two capitals in the names for readability.

So I am trying to figure out what and where I need to change to implement 1)

Thanks in advance

and thanks to Spyros for the excellent work

Oleg

Okay, I have loaded the pdo driver, and this is what I am getting now.

Hello,

First of all, thanks for the extensions. It seems to be very useful and will save me a lot of time if I acomplish to integrate it in my app.

I am new with Yii and a newbie with PHP and my problems maybe something obvious but I cannot solve it. Any help

I have installed srbac correctly in my Yii instance, but every time I try to go to http://localhost/psp/index.php/srbac/authItem/frontpage, I got an exception since AuthitemController try to redirect to install view but I have renamed the directory after instalaltion.

The problem could be related with other odd behaviour I have in my yii instalation. When I use the path documented (http://localhost/psp/index.php?r=srbac/authItem/frontpage) I allways go to the yii home page, that the reason why I am using the other that throws an exception.

This is part of my main.php configuration:




// Components

'components'=>array(

  'db'=>array(

    'class'=>'CDbConnection',

    'connectionString'=>'mysql:dbname=psp',

    'username'=>'root',

    'charset'=>'utf8',

  ),

		

  // Role-Based Access Control

    'authManager'=>array(

    'class'=>'CDbAuthManager',

    'connectionID'=>'db',

    // The itemTable name (default:authitem)

    'itemTable'=>'Permiso',

    // The assignmentTable name (default:authassignment)

    'assignmentTable'=>'AsignacionPermiso',

    // The itemChildTable name (default:authitemchild)

    'itemChildTable'=>'PermisoHijo',			

  ),  


), // components

	

// Modules

'modules'=>array (

  'srbac' => array(

    'userclass'=>'Usuario',

    'userid'=>'idUsuario', 

    'username'=>'email', 

    'debug'=>true, 

    'pageSize'=>10,

    'superUser' =>'SuperUsuario', 

    'css'=>'srbac.css', 

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

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

    'alwaysAllowed'=>array(

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

    'userActions'=>array( 

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

    'listBoxNumberOfLines' => 15, 

    'imagesPath' => 'srbac.images', 

    'imagesPack'=>'noia', 

    'iconText'=>true, 

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

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

    'showHeader'=>true,

    'showFooter'=>true,

    'alwaysAllowedPath'=>'srbac.components',

  ),		

),  // modules




I have created a usuario table and I have ran model a crud yiic commands.

If someone needs any other information in order to better know my problem pleass ask me for it.

Thanks a lots and best regads,

Antonio

Hello,

First of all, thanks for the extensions. It seems to be very useful and will save me a lot of time if I acomplish to integrate it in my app.

I am new with Yii and a newbie with PHP and my problems maybe something obvious but I cannot solve it. Any help

I have installed srbac correctly in my Yii instance, but every time I try to go to http://localhost/psp/index.php/srbac/authItem/frontpage, I got an exception since AuthitemController try to redirect to install view but I have renamed the directory after instalaltion.

The problem could be related with other odd behaviour I have in my yii instalation. When I use the path documented (http://localhost/psp/index.php?r=srbac/authItem/frontpage) I allways go to the yii home page, that the reason why I am using the other that throws an exception.

This is part of my main.php configuration:




// Components

'components'=>array(

  'db'=>array(

    'class'=>'CDbConnection',

    'connectionString'=>'mysql:dbname=psp',

    'username'=>'root',

    'charset'=>'utf8',

  ),

		

  // Role-Based Access Control

    'authManager'=>array(

    'class'=>'CDbAuthManager',

    'connectionID'=>'db',

    // The itemTable name (default:authitem)

    'itemTable'=>'Permiso',

    // The assignmentTable name (default:authassignment)

    'assignmentTable'=>'AsignacionPermiso',

    // The itemChildTable name (default:authitemchild)

    'itemChildTable'=>'PermisoHijo',			

  ),  


), // components

	

// Modules

'modules'=>array (

  'srbac' => array(

    'userclass'=>'Usuario',

    'userid'=>'idUsuario', 

    'username'=>'email', 

    'debug'=>true, 

    'pageSize'=>10,

    'superUser' =>'SuperUsuario', 

    'css'=>'srbac.css', 

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

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

    'alwaysAllowed'=>array(

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

    'userActions'=>array( 

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

    'listBoxNumberOfLines' => 15, 

    'imagesPath' => 'srbac.images', 

    'imagesPack'=>'noia', 

    'iconText'=>true, 

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

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

    'showHeader'=>true,

    'showFooter'=>true,

    'alwaysAllowedPath'=>'srbac.components',

  ),		

),  // modules




I have created a usuario table and I have ran model and crud yiic commands.

If someone needs any other information in order to better know my problem pleass ask me for it.

Thanks a lots and best regads,

Antonio

Srbac tries to redirect you to the install page because it assumes that srbac is not installed yet.

After the installation are the tables created?

If you revert the install dir to the original name does it tries to install again?

Which version of srbac/yii do you use?

Could you paste here your configuration?

Did you use the auto creation tool to create the AuthItems, or you created them manually?

Thanks for your reply, Spyros.

  • Yes, tables are created.

  • Yes, If I revert the install directory, it tries to install again.

  • Versions are Yii 1.1.0 (r1700) and srbac 1.1.0.1

Best regards,

Antonio.

I used and still use the auto creation tool - I did not know that there is a manual option

Oleg

Thank you, Spyros, it works!

Hello Spyros!

Many thanx for the great job you’ve done. I’m using your extension and it works perfect. I wanted to post a bug but i figure it out with my weird hands =)

Thank you very many =)