[MODULE] SRBAC ?r=srbac

YII::ans,

I followed the SRBAC guide 1.1.0.2. I am unable to process the below request mentioned there.

Then point your browser to /path/to/application/index.php?r=srbac and you will be redirected to the installation

page.

Error 404

Unable to resolve the request "srbac".

This is the second RBAC module i am trying and getting the same error. So it seems that it is not the mistake of the extension.

Can you please explain what is happening here.

What is your actual url you type?

Do you use any UrlManager?

My testdrive home page is at




http://localhost/testdrive/index.php?r=site/index



and I am typing




http://localhost/testdrive/index.php?r=srbac



I am not using any UrlManager

have you put the srbac configuration in your main.php modules array?

Dear Spyros,

Thanks for your quick reply. Here is my config file.




<?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'),


	// autoloading model and component classes

	'import'=>array(

		'application.models.*',

		'application.components.*',

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

	),


	// application components

	'components'=>array(

		'user'=>array(

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

		),

		

		

		// added from larry's page http://blog.dmcinsights.com/2009/11/03/configuring-yii/

                /*

	    'urlManager'=> array(

        'urlFormat'=>'path'

        ),	

		*/

		// uncomment the following to enable URLs in path-format

		/*

		'urlManager'=>array(

			'urlFormat'=>'path',

			'rules'=>array(

				'<controller:\w+>/<id:\d+>'=>'<controller>/view',

				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

			),

		),


		'db'=>array(

			'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',

		),

      	*/

		// uncomment the following to use a MySQL database

		

		'db'=>array(

                        // added for rbac

                        'class'=>'CDbConnection',

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

			'emulatePrepare' => true,

			'username' => 'myusername',

			'password' => 'mypassword',

			'charset' => 'utf8',

		),

                // added for rbac start

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

                ),


                '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.main', //optional defaults to

                                     // application.views.layouts.main, 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'),

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

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

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

                  'imagesPath' => 'srbac.images', //optional defaults to srbac.images

                  'imagesPack'=>'noia', //optional defaults to noia

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

                  'header'=>'srbac.views.authitem.header', //optional defaults to

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

                  'footer'=>'srbac.views.authitem.footer', //optional defaults to

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

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

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

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

                                                  // must be an existing alias

                ),


		// rbac addition ends

		'errorHandler'=>array(

			// use 'site/error' action to display errors

            'errorAction'=>'site/error',

        ),

		'log'=>array(

			'class'=>'CLogRouter',

			'routes'=>array(

				array(

					'class'=>'CFileLogRoute',

					'levels'=>'error, warning',

				),

				// uncomment the following to show log messages on web pages

				/*

				array(

					'class'=>'CWebLogRoute',

				),

				*/

			),

		),

	),


	// application-level parameters that can be accessed

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

	'params'=>array(

		// this is used in contact page

		'adminEmail'=>'pannet1@example.com',

	),

	

);



my YII framework and testdrive application is outside my webroot




YII: /home/pannet1/Templates/yii

testdrive webapp: /home/pannet1/Templates/yii/testdrive/

testdrive home page




View file: /home/pannet1/Templates/yii/testdrive/protected/views/site/index.php

Layout file: /home/pannet1/Templates/yii/testdrive/protected/views/layouts/main.php



i am exposing only the testdrive folder as softlink under my webroot like


/home/pannet1/public_html/testdrive

could this be causing the trouble.

You have put srbac in the components array

You must create a modules array and put srbac config in there

Dear Spyros,

Thanks.

Now it redirects to install page and throws up the below error.

include(User.php): failed to open stream: No such file or directory

I will check the thread to see if you have already given a solution.

Do you have a User class in your application?

No. Where should I create it and what should be basic contents of it.

As i said, I am starting from the scratch with a minimalistic testdrive application.

You should have a User model with at least a user_ID and username attributes

Check the tutorials and the blog demo for details

You could also check the srbac blog demo :

http://www.yiiframework.com/extension/srbac/files/yii_blog_demo-srbac_1.1.1rc2.zip

Dear Spyros,

Thank you so much, I will definitely, let you know the outcome.

Dear Spyros,

It is working now after creating a User class. Now I want to know how to replace the default user/user and admin/admin with the one i created (tbl_user). Otherwise, the two (rbac/login) systems seems to be disconnected. In the config, I replaced the line that reads CDBAuthManager into SDBAuthManager.

Can you please help me, I am struck now.

Sorry ignore this. I need to have first implemented the user authentication system as per the example blog application, before RBAC. it is all working now. thanks once again.

Hi

here is the latst version

blog-srbac_1.2_r228.zip

is srbac modules support with postgres, have you been tried before ?

Thank’s Anyways