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

This happens because of a change in 1.1.4 (automatic action parameter binding)

I should fix it in SVN soon

Heya, I have a problem.

I’ve installed srbac on my second application, seemed to retrace all the steps I did in the first, checked with manual but it doesn’t do the user->checkAccess(). My single user is assigned an admin role, under which the srbac should be available. But even that doesn’t work once I turn off the debug mode… :(

I have my controller extended from SBaseController, in the config I have this:





'import'=>array(

	'application.models.*',

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

	'application.components.*',

	'application.extensions.*',

        'application.modules.srbac.components.*',

),


   'modules'=>array(

       'srbac' => array (

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

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

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

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

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

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

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

		'layout'=>'application.views.layouts.main', //optional defaults to

		// application.views.layouts.main, must be an existing alias

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

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

			'SiteError', 'SiteContact'

		),

		'userActions'=>array(//optional defaults to empty array

			'Show','View','List'

		),

		'listBoxNumberOfLines' => 30,

		'alwaysAllowedPath'=>'srbac.components', //optional defaults tosrbac.components

		// must be an existing alias

        ),

    ),


    components (

       'db'=>array(

            'class'=>'system.db.CDbConnection',

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

			'emulatePrepare' => true,

			'username' => 'root',

			'password' => '123456',

			'charset' => 'utf8',

            'enableProfiling' => 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',

            'defaultRoles'=>array('guest'),

        ),


    ),



Is srbac installed successfully?

Which version of Yii do you use?

Yes it installed without any errors, and I use the latest Yii in SVN.

It must be the same bug with the previous post (auto param binding in yii.1.1.4)

I fixed it but I can’t commit it to svn now

Check if your auto created auth items have the $id or something like that in the end

Then make this change in AuthItemController.php

line 716

from:




<?php 

   $action = trim(substr($line, strpos($line, "action")));

    	$patterns[0] = '/\s*/m';

    	$patterns[1] = '/\(/m';

    	$patterns[2] = '/\)/m';

    	$patterns[3] = '/\{/m';

    	$replacements[2] = '';

    	$replacements[1] = '';

    	$replacements[0] = '';

    	$action = preg_replace($patterns, $replacements, trim($action));

?>



to:




<?php 

  $action = trim(substr($line, strpos($line, "action")));

    	$patterns[0] = '/\s*/m';

    	$patterns[1] = '#\((.*)\)#';

    	$patterns[2] = '/\{/m';

    	$replacements[2] = '';

    	$replacements[1] = '';

    	$replacements[0] = '';

    	$action = preg_replace($patterns, $replacements, trim($action));

?>



This is not it :(

Though I had that problem too, I was fixing it manually, so still thanks…

But that doesn’t resolve my problem.

And srbac works fine on my first project. Doesn’t work on this one…

Still I think I might be missing something, some configuration. Though I double-triple checked the values,

the configuration file parts are identical. The Controller class extended correctly… Was there something else?

I seem to have found the problem, but I can’t find how to fix it…

Yii::app()->user->getId() returns username for some reason.

Any suggestions?

This is the default behavior for Yii::app()->user

check here:

http://www.yiiframework.com/doc/guide/topics.auth

Tnx! Finally fixed everything… I missed the overriding function! :)

I have problem with srbac (1.1.1 r209) in IE.

When I try click on User list in Users tab, "Assigned Roles" and "Not Assigned Roles" list boxes is empty. The are similar situation in Roles and Tasks tabs also.

p.s. In Firefox and Opera it work fine.

Thank you,

Nikolai

Hi Spyros!

Thanks for your great work!

As a newbie I ran in a very stupid problem:

Alias "modules.srbac.components.SDbAuthManager" is invalid. Make sure it points to an existing directory or file.

This was easy fixed by typing "application.modules.srbac.components.SDbAuthManager" instead.

Maybe you can correct the srbac guide.

Thanks so much Spyros for this wonderful extension. This is only my 9th hour studying Yii framework and I have to say your extension rocks. :)

Earlier I experienced the error "Property "CWebApplication.authManager" is read only." , and found out that my authManager is outside the components array. My apologies if this was already pointed out, just wanted to help other newbies with this same problem.

More power man!

Bug: Table name prefixes are not honored when tables are generated.

Thank you for the extension.

Unfortunately, I cannot find a hint in the documentation, neither in the code how to configure srbac autocreate authitems to create items for my standard controllers and theit actions. My controllers are in the normal application/protected/controllers directory.

When pressing the button autocreate, the resulting table looks like (where Controllers and Actions is emtpy. The only results are the SRBAC controllers):

Controller Actions

Module: srbac

AuthitemController

SBaseController

Can anyone help?

I guess that your controllers extend Controller (found in components dir).

Just make Controller extend SbaseController and not CController

Thank you for your answer. I figured that out too this morning, by studying your code. Unfortunately (at least for my understanding) the srbac docu guide reads like you have to extend the SBaseController only if you want to have automatic access check (and not autocreation).

Demo link seems to be down?

include_once(/~/www/spyros.agilityhoster.com/demos/protected/modules/srbac/controllers/AuthItemController.php/../SBaseController.php) [<a href=‘function.include-once’>function.include-once</a>]: failed to open stream: No such file or directory

Would it cost much to create some examples of how to implement it correctly?

In other extensions, it explains in detail how to do it step by step, why not this extension?

There are many people interested in this extension.

Greetings

There is an error I encountered when I used the latest srbac(srbac_1.1.1_r209). I encountered this during an update and adding an operation (see images attached).

What I really want to say is, I hope there’s a newbie-friendly documentation for this (new to rbac logic at least). I find this extension very promising, and I think it will gain more audience if can it reach out to yii professionals wannabe (in which I think I belong :D)

More power to SRBAC!

I’ve translated the latest el_gr messages file to Dutch (nl/nl_be/nl_nl).

You can download the tar file here.