[EXTENSION] Rights

@marko: This problem does not seem to be related to rights because it seems that the web user is invalid when doing your checkAccess()-call. Try to debug this by checking why the checkAccess()-call is not done to RightsWebUser but instead to stdClass. I might be able to help you if you provide me with the callback trace.

Please note that you should not use checkAccess to check for roles or you won’t be able to assign the permission to other roles. In away your hard-coding a permission to your admin-role. Instead you should create an operation that you assign to the ‘admin’-role and then check for permissions to that operation.

I’ve hosted a demo on which you can try out the upcoming version of Rights.

Try out the demo

Feel free to try it out!

Please contact me if it doesn’t work or seems messed up and I will fix it as soon as possible. You may also restore the database by logging in and using the ‘Restore Database’ in the maintenance menu which can be found on the front page.

About the next version of Rights, it should be ready soon. I’m still doing some improvements and then I need to thoroughly test it before I can ship it.

It would be great if people who like Rights would contribute by testing the upcoming version on my demo installation. This way I could get the new version out sooner and you could get some insight on what kind of improvements are on the way.

I found this worked for me to set custom table names:




    'authManager'=>array(

         'class'=>'RightsAuthManager',	// provides support for authorization item sorting

         // The itemTable name (default: AuthItem)

          'itemTable' => 'tbl_auth_item',

         // The assignmentTable name (default: AuthAssignment)

         'assignmentTable' => 'tbl_auth_assignment',

         // The itemChildTable name (default: AuthItemChild)

         'itemChildTable' => 'tbl_auth_item_child',

         // The rightsTable (default: AuthItemWeight)

         'rightsTable' => 'tbl_auth_item_weight',

    ),



Edit - the above code is for Rights version 1.1.0. If you have upgraded to 1.2.0 (see below), the class should be renamed to ‘RDbAuthManager’.

Version 1.2.0 is now available.

NOTE! Upgrading to version 1.2.0 requires you to read this post and make the necessary changes to your application and its configuration. I apologize for the inconvenience.

In order to update your existing installation of Rights you need to do the following things:

[list=1]

[*]Change your web user class to ‘RWebUser’ (previously RightsWebUser)

[*]Change your auth manager class to ‘RDbAuthManager’ (previously RightsAuthManager)

[*]Change your application controller (normally called Controller) to extend RController (previously RightsBaseController)

[/list]

The component classes were renamed in order to improve consistence within the module. Once again I apologize for the trouble this might have caused you.

New features are:

  • Assigned items are now divided into three columns (Roles, Tasks and Operations) under Assignments.

  • Configuration parameter for whether to display item description instead of name

  • Configuration parameter for the application layout.

  • Removed the guestName configuration parameter, web user guestName will be used instead

  • Return URLs are now stored with the web user

  • Authorization item names are now URL encoded when passed as get parameters

  • A great deal of code quality improvements

The documentation has also been updated and can be found at:

http://yii-rights.googlecode.com/files/yii-rights-doc-1.2.0.pdf

I hope you all enjoy the new version of Rights, as normally please report any bugs you might find on google code and I will take a look as soon as possible.

How about if you combination ext right to have user include in your ext spesificly

Hello,

I am trying to install rights module (yii-rights-1.2.0.r139.zip). When I go to URL http://localhost/test/index.php?r=rights, I get the following error.

CException

Description

Application authorization manager must extend the RightsAuthManager class.

Source File

D:\wamp\www\test\protected\modules\rights\components\RInstaller.php(49)

The following 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.user.models.*',

        'application.modules.user.components.*',

        'application.modules.rights.*',

        'application.modules.rights.components.*',


	),


	'modules'=>array(

		

		 'user',

		 'rights'=>array(

		 	'install'=>true, // Enables the installer.

		 ),


	),


	// application components

	'components'=>array(

		'user'=>array(

			// enable cookie-based authentication

            'allowAutoLogin'=>true,

            'loginUrl' => array('/user/login'),

			'class'=> 'RWebUser',

		),


		'authManager'=>array(

			'class'=>'RDbAuthManager', // Provides support authorization item sorting. ......

		),


		'db'=>array(

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

			'emulatePrepare' => true,

			'username' => 'root',

			'password' => '12345',

			'charset' => 'utf8',

		),


		'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'=>'webmaster@example.com',

	),

);




I have created users table and User Model and extended my Controller class from RController but I am unable to resolve this error. Can you point me in the right direction?

Regards,

Hello,

I have fixed my issue. I modified the code of RInstaller.php

line# 48 to

if( ($authManager instanceof RDbAuthManager)===false )

and line#54 to

if( ($user instanceof RWebUser)===false )

and it started working.

Was that the problem or is there some thing wrong with the config file?

Hello Sadaf,

Thanks for reporting this issue. I totally forgot to change the installer. I will repack the module and release it tonight. I apologize for the inconvenience.

Oh come on, what inconvenience, you saved a LOT of my time. I am glad that I can be of any help :)

Thanks for the module.

Your welcome! The pleasure is all mine. :)

hehehehe i have the same problem, i just comenting out that line, waiting for the fix :)

thx for the module too :)

This issue is fixed in the latest version available for download (1.2.0.r142).

Hi Chris, thanks again for your great work!

I’m trying to implement this with Rights. Do you have suggestions where to start?

I think this is very application-specific, and it might discourage some ‘rights’ users for it will become rigid.

If you want an extension to be used with rights, try yii-user (not yii-user management, it requires a different class for user components). Install yii-user first before rights of course. :)

hwa thx alot…

Hi, firstable great job!

I was trying to install rights in a default yii installation with sqlite but it doesn’t work. The problem is the code used to generate the tables: sqlite doesn’t support type InnoDB. Once removed that from the CREATE statements in RInstaller.php, it installed fine.

At first I thought the sql code was read from data/schema.sql[size=“1”], but it’s hardcoded into RInstaller.php[/size].

BTW, the install process silently redirected me to the index page without any warning or error… only when I used a CFileLogRoute the issue was shown in the log (not even the CWebLogRoute nor ytdebugtoolbar showed it…wierd).

thank you four your great job!!

When I configure


        

'rights' => array(

    'language' => 'es',

),



I receive an error


CException

Description

Property "RightsModule.language" is not defined.

Source File

D:\Soft\yii-1.1.5.r2654\framework\base\CModule.php(467)

(...)

Stack Trace


#0 D:\Soft\yii-1.1.5.r2654\framework\base\CModule.php(467): CComponent->__set('language', 'es')

#1 D:\Soft\yii-1.1.5.r2654\framework\base\CModule.php(69): CModule->configure(Array)

#2 D:\Soft\yii-1.1.5.r2654\framework\YiiBase.php(200): CModule->__construct('rights', NULL, Array)

#3 D:\Soft\yii-1.1.5.r2654\framework\base\CModule.php(266): YiiBase::createComponent('rights.RightsMo...', 'rights', NULL, Array)

#4 D:\Soft\yii-1.1.5.r2654\framework\web\CWebApplication.php(379): CModule->getModule('rights')

#5 D:\Soft\yii-1.1.5.r2654\framework\web\CWebApplication.php(318): CWebApplication->createController('rights/assignme...')

#6 D:\Soft\yii-1.1.5.r2654\framework\web\CWebApplication.php(121): CWebApplication->runController('rights/assignme...')

#7 D:\Soft\yii-1.1.5.r2654\framework\base\CApplication.php(135): CWebApplication->processRequest()

#8 D:\Proyectos\work\cronos\www\index.php(13): CApplication->run()

#9 {main}



‘es’ actually exists in messages …

You make a very good point about the installer. I’ll see about changing the installer to actually use the schema, it shouldn’t be a problem. Thanks for the great idea!

I also have to think about generalizing the schema because it’s actually not a requirement for the tables to be InnoDB, just something I’m used to.

About the install failing, it should display an error message but I have to double check this. Thanks for pointing this out.

Rights uses your application language, you cannot configure it’s language separately.

Do you think that it’s necessary to configure it’s language to be different than your application language?

you’re absolutely right. I read the “Internationalization” part of the documentation too fast. I clearly says the setting is for the application, not for rights. No sense in having a different language.

thank you again!