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

Could you send me the file so I can add in in the downloads?

ok,I attached it and should be put into the message directory.

my website is now at:

http://sys2009.200u.com/Belief

如果你在大陆,那么您需要使用国外代理访问本站,虽然此免费空间很快,可是被中共屏蔽。对于国外的朋友,没有关系。

建议您下载一些代理软件工具无障碍访问所有网址,例如:向国外朋友求助。

Hello to everybody!

I’ve got some problems with installing this cool module.

I’ve got red-highlighted property “layout - application.views.layouts.admin”

And i have no idea how to solve it. It seems that i have to put some file "admin.php" into the folder /protected/views/layouts/ . where can i download this file ?

Could You give me some directions?

This is an example

If you want srbac to use your default layout ignore this setting (comment it)

If you have a different layout for youw administration pages set the alias to that layout

I have tryed to leave it blank , but it still says that there is an error

i’ve puted some debug code into your script /protected/modules/srbac/views/authitem/install/install.php ( near line 99 )




        <?php foreach ($this->module->getAttributes() as $key=>$value) { ?>

          <?php $check = Helper::checkInstall($key,$value); ?>

          <?php echo $check[0]; ?>

          <?php if($check[1] == 1)  $error = true; 

                   if($error) {echo "<hr>"; var_dump($key);var_dump($value);var_dump($check);}?>

        <?php } ?>

      <?php  } catch(CException $e ) { ?>



and the output is




string 'layout' (length=6)


string '' (length=0)


array

  0 => string '<tr><td valign='top'>layout</td><td><div class='installError'></div><div class='installError'></div></td>' (length=105)

  1 => string '1' (length=1)

  2 => string '' (length=0)



i’ve changed file Helper.php (near 432)




      case ($key == "layout" || $key == "notAuthorizedView" || $key == "imagesPath"

          ||$key == "header" || $key == "footer"):

        $class = "installNoError";

        if($value != '') {

            $file = Yii::getPathOfAlias($value).".php";

            $path = Yii::getPathOfAlias($value);

            if(!file_exists($file) && !is_dir($path)) {

                  $class = "installError";

                  $out[1]="1";

            }

        }

        break;



and it said , that the instalation is ok, but it still redirects me to the installation.

Your site says After the installation delete or rename the install folder, but the only "install" folder that i see , is in "views/authitem"

Don’t leave it blank, just don’t put it in the configuration, or comment it




<?php

srbac => array (

  .... 

  'css'=>'srbac.css',

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

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

  .....

)

?>




when i install, the page show: "There is an error in your configuration "

but i can’t get error message. there is some method to get error information. i set debug true;

Check in your configuration that the css file really exists (set it to srbac.css for sure).

If the css file is configured then the configuration errors will be shown with red color

Hi Spyros, I’m testing your module and it looks really great. Thank you for it :)

I’d like to ask to ask You 2 questions:

  1. in beforeAction($action) of SBaseController there is:



// Check for srbac access

if(!Yii::app()->user->checkAccess($access) || Yii::app()->user->isGuest) {

  $this->onUnauthorizedAccess();

} else {

return true;

}



Basically it disallows everything to Guests and is not very flexible. Wouldn’t be better to remove “|| Yii::app()->user->isGuest”? After removing user without proper group/task assigned is still blocked.

[edit]

Few more words about this. I have default role "guest". Its not hard to guess that its role for non-authenticated users. I assigned tasks and operations but "guest" user is still blocked by this if.

  1. What do you think about leting of assigning tasks to tasks? It would be nice feature in situation when one role is ‘successor’ of other.

Hi,

before this code is the check for the guest accounts




<?php

//Always allow access if $access is in the allowedAccess array

    if(in_array($access, $this->allowedAccess())) {

      return true;

    }

?>



The attribute allwaysAllowed is an array of all controllers/actions that are allowed to anyone (even guests)

You can edit it by modifying the alwaysAllowed attributeby :

  1. setting it to an array of allowed auth items (eg "alwayAllowed"=> array("SiteLogin","SiteIndex","PostView"))

2.By pointing to a php file that returns an array of allowed auth items (eg "alwayAllowed"=> "application.components.alwaysAllowed" which points to alwaysAllowed.php in components subdir)

  1. Set it to gui (eg "alwayAllowed"=> "gui") and use the built in gui to edit the always allowed file.

That seems very difficult to implement in the assign tabview GUI

True, it seems difficult…

And about guests - “alwaysAllowed” approach still doesn’t work when you try to allow some actions only for guest users.

Once again - thanks for great module :)

Maybe there’s a bug in the alwaysAllowed thing. I’ll check and let you know

edit:

I fixed an import in SBaseController line 64 function should be




<?php

 protected function allowedAccess() {

    Yii::import("srbac.components.Helper");

    return Helper::findModule('srbac')->getAlwaysAllowed();

  }

?>



That was throwing an error not a not authorized message so I don’t know if it will fix your case. Anyway try it and let me know

I have always page not found :S I don’t understand why.

Mayby i was not clear enough. Everything works ok for me. But I want to allow some actions only for guest. When user is authenticated he/she cant access some actions. And with "alwaysAllowed" it doesnt work because these gives access for everyone. So I created guest group and give it some tasks (ONLY for guests) but than this code

"|| Yii::app()->user->isGuest) {" is blocking guest user even when he has valid access.

sorry for the question but I copy srbac in modules folder I use url rewrite and when I search http://www.localhost/myapplication/srbac I don’t find anything, I follow all the instruction without resolution have you an idea?

sorry for my english. :P

Oh, Now I see

Maybe you can should set the Yii::app()->user->isGuest to false when a user visits the page and given the user role.

do you use a urlManager rule, or do have your index.php hidden?

What is the url to your main page?

http://87.19.34.191/hotelmanager/ it’s in localhost I hidden index.php and have some rule

Which version of srbac do you use?

try this

http://87.19.34.191/hotelmanager/srbac/authitem/install for install page and

http://87.19.34.191/hotelmanager/srbac/authitem/frontpage for main page

I use the latest srbac version find on this site I try both the link without result it’s very strange I post here my conf/main.php


<?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(

	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',

	'name'=>'My Web Application',

	// preloading 'log' component

	'preload'=>array('log'),

		//tema

	'theme'=>'base',

	'sourceLanguage'=>'it',

	// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

		 'application.controllers.*',

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

	),


	// application components

	'components'=>array(

	'file'=>array(

        'class'=>'application.extensions.file.CFile',

		'authManager'=>array(

				  // The type of Manager (Database)

				  'class'=>'CDbAuthManager',

				  // The database component used

				  'connectionID'=>'db',

				  // The itemTable name (default:authitem)

				  'itemTable'=>'item',

				  // The assignmentTable name (default:authassignment)

				  'assignmentTable'=>'assignment',

				  // The itemChildTable name (default:authitemchild)

				  'itemChildTable'=>'itemchild',

				),

    ),

    

	'thumb'=>array(

            'class'=>'application.extensions.phpthumb.EasyPhpThumb',

        ),

		'log'=>array(

			'class'=>'CLogRouter',

			'routes'=>array(

				array(

					'class'=>'CFileLogRoute',

					'levels'=>'error, warning',

				),

			),

		),

		'user'=>array(

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

			'loginUrl'=>"login",

		),

		'modules'=>array(

				'srbac' => array(

				  'userclass'=>'user',

				  'userid'=>'user_ID',

				  'username'=>'username',

				  'debug'=>true,

				  'pageSize'=>10,

				  'superUser' =>'Authority',

				  'css'=>'srbac.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,

				  'imagesPath' => 15,

				  'imagesPack'=>'noia',

				  'iconText'=>true,

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

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

				  'showHeader'=>true,

				  'showFooter'=>true,

				),

			),

					

		// uncomment the following to set up database

		

		'db'=>array(

			'connectionString'=>'mysql:host=localhost;dbname=Yii','username'=>'user', 'password'=>'pass', 'charset'=>'utf8',

		),

		

		'urlManager'=>array(

            'urlFormat'=>'path',

			 'showScriptName'=>false,

            'rules'=>array(

				//site section

				'/login'=>array('site/Login','showScriptName'=>false,),

                '/hotel-<stelle:(2|3|4|5)>-stelle-ischia'=>array('site/hotel_ischia','urlSuffix'=>'.html','showScriptName'=>false,),

				'/hotel-<comune:(ischia-porto|casamicciola-terme|lacco-ameno|forio|barano|serrara-fontana)>'=>array('site/hotel_ischia','urlSuffix'=>'.html','showScriptName'=>false,),

				'/<categoria:(hotel|residence|bandb|appartamenti)>-ischia'=>array('site/hotel_ischia','urlSuffix'=>'.html','showScriptName'=>false,),

				'/<categoria:(hotel|residence|bandb|appartamenti)>-<stelle:(2|3|4|5)>-stelle-<comune:(ischia-porto|casamicciola-terme|lacco-ameno|forio|barano|serrara-fontana)>'=>array('site/hotel_ischia','urlSuffix'=>'.html','showScriptName'=>false,),

				'/<categoria:(hotel|residence|bandb|appartamenti)>-<comune:(ischia-porto|casamicciola-terme|lacco-ameno|forio|barano|serrara-fontana)>'=>array('site/hotel_ischia','urlSuffix'=>'.html','showScriptName'=>false,),

				'/<hotel:(grilli|letizia)>'=>array('site/Hotel','urlSuffix'=>'.html','showScriptName'=>false,),

				

            ),

		),

	),


	// application-level parameters that can be accessed

	// using Yii::app()->params['paramName']

	'params'=>array(

		// this is used in contact page

		'adminEmail'=>'xjackassx@gmail.com',

	),

	

);