[EXTENSION] Rights

Hello, I’m having some issues with Rights.

Ok, so the authentication simply does not work. I realised that if I change the values of userid column in the authassignment table from user id to user name it will work…

Dear all

First of all thank you Chris for "rights" and users contributing in this forum to let people use it at best! need help, want to know the missing part in yii rights module implementation.

  • module successfully installed (both user & rights)

  • removed access rules from main controller

  • can view the panel with option

    Assignments

    Permissions

    Roles

    Tasks

    Operations

  • created roles, assigned to user.

for example: sub admin to create users, assigned that to newly created user.

  • the new user is not working with assigned rights.

Whats the missing step?

Thanks in Advance.

How do you manage to edit the userid column and set its value to 1 can you write the mysql code. for this.

Hi Chris

I have this error on my installation can you help me out on this please.

Anyone is much appreciated.

[b]

[/b]

Error 403

[color=#555555][font=Arial, Helvetica, sans-serif]There must be at least one superuser![/font][/color][color=#555555][font=Arial, Helvetica, sans-serif]

[/font][/color][color=#555555][font=Arial, Helvetica, sans-serif]Best Regards.[/font][/color]

I’m using phpmyAdmin ;)

I have a problem, please help me.

CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (demo.authassignment, CONSTRAINT authassignment_ibfk_1 FOREIGN KEY (itemname) REFERENCES AuthItem (name) ON DELETE CASCADE ON UPDATE CASCADE). The SQL statement executed was: INSERT INTO AuthAssignment (itemname, userid, bizrule, data) VALUES (:itemname, :userid, :bizrule, :data)

it’s after adding assign item to roles.

Hello. I installed yii-rights, which created 4 db tables: AuthAssignment, AuthItem, AuthItemChild, Rights. First 3 dbtables: AuthAssignment, AuthItem, AuthItemChild are populated with data, but last table: Rights is always blank. Is this normal situation?

Thanks for reply

Tom

I have two Controllers

1.CustomercareController

2.ReportsController

And i have created some new role for account to reports and ccare to customercare.

Images are attached.

Problem:-

When logged in with Accountant i can access all the controller actions of both controllers.

Is there anything i have to change in Controllers?

OR should do some change in business rules.

Please guide me what i missed.

SOLVED:- Forgot to apply filters in controllers. and extend RController.

[size="3"][center]How to install the Rights without error 403![/center][/size]

  1. First of all, you must configure authentication using a database. You must configure the creation, deletion user using the database, as well as the login to the site. The users table must be named ‘users’.

I use a table users like this:


CREATE TABLE IF NOT EXISTS `users` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `login` varchar(50) NOT NULL,

  `pass` varchar(50) NOT NULL,

  `email` varchar(32) NOT NULL,

  `lang` varchar(2) NOT NULL DEFAULT '',

  `rememberme` int(1) NOT NULL DEFAULT '0',

  `regdate` datetime NOT NULL,

  `last_update` datetime NOT NULL,

  `last_comin` datetime NOT NULL,

  `active` int(1) NOT NULL,

  PRIMARY KEY (`id`)

) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

  1. Create a user with the username ‘admin’. His id should be 1 (id=1)

Install the Rights.

  1. Unpack the archive in protected/modules/rights

  2. Correct the config/main

in Import section:


'import'=>array(


'application.modules.rights.*',

'application.modules.rights.components.*',   // Correct paths if necessary. 

),

in Components section:


'components'=>array(


'user'=>array(

'class'=>'RWebUser',      // Allows super users access implicitly.

//'defaultRoles'=>'Guest',

),



in authManager section:


'authManager'=>array(

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


),

in modules section:


'modules'=>array(

		'rights' => array (

				'superuserName' => 'SuperAdmin',

				'authenticatedName' => 'Authenticated',

				'userClass' => 'Users',

				'userIdColumn' => 'id', // Name of the user id column in the database.

				'userNameColumn' => 'login', // Name of the user name column in the database.

				'enableBizRule' => false, // Whether to enable authorization item business rules.

				'enableBizRuleData' => false, // Whether to enable data for business rules.

				'displayDescription' => true, // Whether to use item description instead of name.

				'flashSuccessKey' => 'RightsSuccess', // Key to use for setting success flash messages.

				'flashErrorKey' => 'RightsError', // Key to use for setting error flash messages.

				'baseUrl' => '/rights', // Base URL for Rights. Change if module is nested.

				'layout' => 'rights.views.layouts.main', // Layout to use for displaying Rights.

				'appLayout' => 'webroot.themes.office.views.layouts.main', // Application layout.

				//'appLayout' => 'application.modules.admin.views.layouts.main', // Application layout.

				//'cssFile' => 'rights.css', // Style sheet file to use for Rights.


			'install' => false,

		),

),



  1. Make sure that

'install' => true,

  1. Entering a site under the ‘admin’ account

  2. Call mysite/index.php?r=rights or mysite/index.php/rights.

Get:

Congratulations! Rights has been installed succesfully…

or not … ;))

If you are use ‘login’ field in the table ‘users’ as I am, but not the field ‘name’ as conceived by the author,

You get famous Error 403 There must be at least one superuser!.

You have two ways:

1. Use a table ‘users’ like this


CREATE TABLE IF NOT EXISTS `users` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `user` varchar(50) NOT NULL,

  `pass` varchar(50) NOT NULL,

  `email` varchar(32) NOT NULL,

  `lang` varchar(2) NOT NULL DEFAULT '',

  `rememberme` int(1) NOT NULL DEFAULT '0',

  `regdate` datetime NOT NULL,

  `last_update` datetime NOT NULL,

  `last_comin` datetime NOT NULL,

  `active` int(1) NOT NULL,

  PRIMARY KEY (`id`)

) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

and run again.

2. Make such magical passes:

2.1. in components/RAuthorizer.php, around line 300, change


$superusers[] = $user->name;

to


$superusers[] = $user->{Rights::module()->userNameColumn};

2.2. in /protected/components/UserIdentity.php add lines:


$this->username = $rec->login;

$this->setState( 'userlogin', $rec->login );

$this->setState( 'name', $rec->name );

(my rquest is: $rec = Users::model()->findByAttributes( array ( ‘login’ => $this->username ) ); )

2.3. ALTER TABLE users ADD name VARCHAR( 64 ) NULL AFTER login;

2.4. Assign the "admin" value to the "name" field

2.5. Entering under the username ‘admin’ and call mysite/index.php?r=rights или mysite/index.php/rights

Get:

Congratulations! …

Now we return everything back

2.6. Delete the line


$this->setState( 'userlogin', $rec->login ); 

in /protected/components/UserIdentity.php

2.7. ALTER TABLE users DROP name

2.8. Set


'install' => false,

in config/main


And finally,

It is also important that the names of the tables had such this: (note the capital letters)

AuthAssignment, AuthItem, AuthItemChild and Rights

Regards, guys

Can anyone help me?

How to configure the module to work with the Oracle?

check this:

http://www.yiiframework.com/wiki/296/troubleshooting-rights-extension/

Is there a way to uninstall the extension from my Yii project?

Hi, I

I am using the RBAC in my Application. I want to show the access levels for user choice.

How to do it?

for example show permission in tree view(all permission or special roles)

[b]Hi !,

Arrived at step 8, I get the error message 'Application manager must extend the authorization RDbAuthManager class. "

Any idea?[/b]

The version I am trying to install is: yii-rights-1.3.0.r147

File Config (Main.php)




<?php


// uncomment the following to define a path alias

// Yii::setPathOfAlias('local','path/to/local-folder');

Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');


// 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.rights.*',

		'application.modules.rights.components.*',   // Correct paths if necessary. 

	),


	'modules'=>array(

		// uncomment the following to enable the Gii tool

		/*

		'gii'=>array(

			'class'=>'system.gii.GiiModule',

			'password'=>'Enter Your Password Here',

			// If removed, Gii defaults to localhost only. Edit carefully to taste.

			'ipFilters'=>array('127.0.0.1','::1'),

		),

		*/

	),


	// application components

	'components'=>array(

		'user'=>array(

			// enable cookie-based authentication

			'allowAutoLogin'=>true,

			'class'=>'RWebUser', // Allows super users access implicitly.

		),

		'authManager'=>array( 

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

			'connectionID'=>'db',

		),

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

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

			'emulatePrepare' => true,

			'username' => 'root',

			'password' => 'root',

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

	),

	

	    'theme'=>'bootstrap', // requires you to copy the theme under your themes directory

		'modules'=>array(

			'gii'=>array(

				'generatorPaths'=>array(

					'bootstrap.gii',

				),

			),

			'rights' => array (

                'superuserName' => 'SuperAdmin',

                'authenticatedName' => 'Authenticated',

                'userClass' => 'users',

                'userIdColumn' => 'id', // Name of the user id column in the database.

                'userNameColumn' => 'login', // Name of the user name column in the database.

                'enableBizRule' => false, // Whether to enable authorization item business rules.

                'enableBizRuleData' => false, // Whether to enable data for business rules.

                'displayDescription' => true, // Whether to use item description instead of name.

                'flashSuccessKey' => 'RightsSuccess', // Key to use for setting success flash messages.

                'flashErrorKey' => 'RightsError', // Key to use for setting error flash messages.

                'baseUrl' => '/rights', // Base URL for Rights. Change if module is nested.

                'layout' => 'rights.views.layouts.main', // Layout to use for displaying Rights.

                'appLayout' => 'webroot.themes.office.views.layouts.main', // Application layout.

                //'appLayout' => 'application.modules.admin.views.layouts.main', // Application layout.

                //'cssFile' => 'rights.css', // Style sheet file to use for Rights.


                'install' => true,

			),

		),

    'components'=>array(

        'bootstrap'=>array(

            'class'=>'bootstrap.components.Bootstrap',

        ),

    ),


);



Hello,

I am new in Yii framework. I want to use your extension, but can’t see demo. I use Chrome browser. I already logon with admin/admin. What I need to do?

With regards,

KnaingKo

All,

I’m quite new to Yii, so I hope I haven’t overlooked something simple and obvious through my searching of documentation.

I believe rights was successfully installed on my machine (I can add things, and they are populated in my database…). The problem is that the authorization seems to be failing. I believe this is due to the fact that Yii doesn’t think the admin user is actually a superuser.

I’ve attached screen shots of code that displays if the logged in user isSuperuser and a dump of the array supeusers from the rights module.

Can anyone explain why rights has the superusers in it’s array, yet the logged in user is not set to superuser? Also, I’m logged in as ‘kirk’ and thus have access to ‘rights’ but no other page…

Controllers filters are set to ‘rights’. Controllers are extending RController. I only have the rights module (no yii users extension).

If more info is required, I’ll be more than happy to give you more. Thanks in advance!

Also, I’m using Yii 1.1.13. (Although I’m certain this is not part of the issue as the blog demo runs correctly using the same yii framework…).

<------------------------->

Solved it. It was an error in the database and Yii configuration. Yii was using a column (username) to assign the user->id verses rights using the column user_id. Once I created my own _id and assigned it the correct id and fixed the columns in my database it worked.

Using Yii-rights + Yii-user module in my project. In Rights, I generated operations based on my controller action, under update I added a child UpdateOwn.

For UpdateOwn, the bizrule is suppose to be a simple comparison that the logged in user’s ID is equal to $model->user_id field.

I understand yii checkaccess allow you to pass in variables as parameters and comparing with your defined bizrule. But how does it work for Yii-rights module? How or what are the data/params passed in to be used in bizrule? How can I define or pass my own data/params?

Hey all, Using Yii Rights and it’s awesome, thanks!!

I have restructured my application to use nested modules (ie. /backend/administration/category/) Administration is a sub module of Backend. Category is a Controller.

When I "Generate controller actions" it creates "Administration.Category.*", however when I try to grant access to this permission to a role, I get a 403.

Is there any issues in using nested modules, and Yii rights?

Thanks!


UPDATE:

Ok, I’ve just run some tests… I’ve looked into RightsFilter.php, and the preFilter() function. $authItem, which is derived from “ucfirst($controller->id);” returns “Backend/administration.Category”.

When the controller items are generated, it generates Administration.Category.*.

So the Administration module (child to "Backend") is being incorporated into the controller name.

Is this me doing something wrong??

Does anyone have any suggestions on how to elegantly fix this?

Cheers

Dan


UPDATE 2:

I’ve modified the rules by changing it from “Administration.Controller.", to be "Backend/administration.Controller.”, which is working.

However I feel I may have done something wrong? Does anyone else have this issue? Or a solution to this issue?

i installed rights successfully ,great extension i got the issue when it uploaded to Linux server

Unable to resolve the request "rights/authItem/roles".

i commented the ‘caseSensitive’=>false, in urlManager path of main.php

now its working :)

I use rights module and has a problem with checkaccess function, example:

  • in MyController (extends RController ):

public function filters()

{

return array(‘rights’);

}

public function allowedActions() {

return ‘index’; //public action

}

===> access to url my/index ok , but Yii::app()->user->checkAccess(‘My.Index’) will be return false if user not an admin. How to check if an action is public action?

Help me, please!