Yii Framework Forum: An idea for Role Based Access Control - Yii Framework Forum

Jump to content

  • (5 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • 5
  • You cannot start a new topic
  • This topic is locked

An idea for Role Based Access Control Rate Topic: -----

#41 User is offline   yogesh_sharma 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 25-March 09

Posted 30 March 2009 - 04:50 PM

Hi,
I was using the RBAC and got following error

>> rbac grant roles=id:2 permissions=id:%
PHP Warning:  Call-time pass-by-reference has been deprecated in protected\commands\shell\RbacCommand.php on line 4
39

What is minimum PHP version I should use or what else I should do to fix it.
0

#42 User is offline   megabr 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 142
  • Joined: 23-March 09
  • Location:Brazil

Posted 30 March 2009 - 04:57 PM

I am using php 5.3
0

#43 User is offline   SlowDown 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 18-March 09

Posted 30 March 2009 - 10:12 PM

Hi, Oleksiy.

I've not try it yet, but I think it is a nice module.
Will much appreciate if you include postgresql dump.

-majin-
0

#44 User is offline   Paul Apostol 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 61
  • Joined: 25-March 09

Posted 02 April 2009 - 11:24 AM

Thanks for the example.
Very nice work
Instead of having php bizRules I will look to see if I can attach access levels.
As ex, for a structure like Holding/Firm/Department/Emplyee to have related access levels over the actions

Paul

PS: I'm missing something or the edit of the roles permisions is not done?
0

#45 User is offline   oleksiy 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 24-February 09

Posted 02 April 2009 - 01:11 PM

Quote

PS: I'm missing something or the edit of the roles permisions is not done?


Something is wrong, editing should be fully working. What happens when you click on 'Edit' link in 'Action' column?
0

#46 User is offline   Paul Apostol 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 61
  • Joined: 25-March 09

Posted 02 April 2009 - 01:56 PM

The problem is under Roles when I'm clicking on Permissions. I think I misunderstood how is working. It shows only the tree (app and model) and the tree is expanding. No other options and no effect on save.
roles_has_permissions is not changed after save.
I created a group "Test" and I don't have a clue how to allocate the permissions.
THX
Paul

EDIT:
It has to be a checkbox tree? I don't have any checkbox. And no JS errors.
A strange tree if I may.

Attached File(s)


0

#47 User is offline   oleksiy 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 24-February 09

Posted 02 April 2009 - 02:11 PM

Looks like an extension is missing: JQueryCheckTree. There should be a collapsable tree with checkboxes.
0

#48 User is offline   Paul Apostol 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 61
  • Joined: 25-March 09

Posted 02 April 2009 - 02:18 PM

I have it. I just unzipped your archive. I've changed only the config for db and framework. I'll investigate and I'll tell you if I found something.
0

#49 User is offline   megabr 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 142
  • Joined: 23-March 09
  • Location:Brazil

Posted 02 April 2009 - 02:20 PM

The system for add users_to_goups when  groups_as_roles need another way to usability... I think.... I am try think how to...

legend: d=del,update=u,create=c,list=l

modules<-has->actions:
-------------------
blog        | d,c,u,l,s
chat        | d,c,u,l,s
-------------------
groups <has> permissions:
-------------------
admin      | d,u,c,l
cpd        | c,l,
user        | l
sup        | u,
--------------------
user_has_groups
example:
-----------------
user        group
-----------------
max        sup
max        cpd
tom        cpd

them user max can/has: roles/permissions sup+cpd=c,l,u

In my case users are part of task groups, in this case the number of records in databse are redused. dramatically,

for example I have 500 users group in 4 level, I setup 4 groups, with especific roles permissions, latter we add same user to corresponding group level.


0

#50 User is offline   Paul Apostol 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 61
  • Joined: 25-March 09

Posted 02 April 2009 - 02:35 PM

Anyway, till I'll found the problem I have a question: User can have multiple roles? Looks like it could.
Also I need an advice. What I need is much more complicated but could be a start.
I need an authorization system that shows to certain users only few of the modules (I'll set them in the main menu) and certain controllers (secondary menu) and they can see only information inserted by them, or inserted by their colleagues in the department, or in the firm, etc. Any advice?
Thank you,
Paul

EDIT:
When the tree is taken through Ajax maybe a script must run.
0

#51 User is offline   SimonZ 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 01-February 09

Posted 02 April 2009 - 05:13 PM

There's a problem in Rbac.php
On Select distinct must change
AND u.id=:id
with
AND u.username=:id

and in RbacFilter.php when access is true i've no vars named
$p['title']  and $p['id']
0

#52 User is offline   oleksiy 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 24-February 09

Posted 03 April 2009 - 02:01 AM

Hi Simon,

You are using old Rbac code, please have a look at the snapshot I've attached few posts before.

and you should use supplied RbacUserLoginIdentity class as User Identity. Then you wont need to change to "AND u.username=:id"

Quote

There's a problem in Rbac.php

On Select distinct must change

AND u.id=:id

with

AND u.username=:id



and in RbacFilter.php when access is true i've no vars named

$p['title']  and $p['id']

0

#53 User is offline   oleksiy 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 24-February 09

Posted 03 April 2009 - 02:05 AM

HI,

1) Yes, user can have multiple roles.

2) There are several solutions for your question. First is to make use of BizRule column, that is business rule - php code that can perform additional checks while evaluating the permission. Second, you can have a separate action, that will only update records that user can update. You will define a separate permission for this action and assign it to some role.

Quote

Anyway, till I'll found the problem I have a question: User can have multiple roles? Looks like it could.

Also I need an advice. What I need is much more complicated but could be a start.

I need an authorization system that shows to certain users only few of the modules (I'll set them in the main menu) and certain controllers (secondary menu) and they can see only information inserted by them, or inserted by their colleagues in the department, or in the firm, etc. Any advice?

Thank you,

Paul



EDIT:

When the tree is taken through Ajax maybe a script must run.

0

#54 User is offline   oleksiy 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 24-February 09

Posted 03 April 2009 - 02:06 AM

This is quite nice idea, I will think about it!

Quote

The system for add users_to_goups when  groups_as_roles need another way to usability... I think.... I am try think how to...

0

#55 User is offline   Paul Apostol 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 61
  • Joined: 25-March 09

Posted 03 April 2009 - 09:36 AM

Hard to chose. I was thinking at both solutions but first is hard to admin if you don't know PHP, second is not very flexible (coded for a specific problem).
Anyway, because I want dropdowns to set the module, controller and actions I was thinking on another idea: to make a set of bizRules to chose from, nicely labeled (another dropdown).
The question is: what's happening on multiple roles on one user? Even for the actual style of bizRules? (because you are able to put the same permission twice, with different bizRules)
Thank you,
Paul
0

#56 User is offline   oleksiy 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 24-February 09

Posted 03 April 2009 - 09:51 AM

If any of  permissions for specified module/controller/action set allows access - then access is granted.

Quote

The question is: what's happening on multiple roles on one user? Even for the actual style of bizRules? (because you are able to put the same permission twice, with different bizRules)

Thank you,

Paul

0

#57 User is offline   megabr 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 142
  • Joined: 23-March 09
  • Location:Brazil

Posted 03 April 2009 - 09:59 AM

Quote

because I want dropdowns to set the module, controller and actions I was thinking on another idea: to make a set of bizRules to chose from, nicely labeled (another dropdown).


about layout, are you looked this image?
http://www.yiiframew...ttach=258;image

posted here:

http://www.yiiframew...00.html#msg7900

0

#58 User is offline   Paul Apostol 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 61
  • Joined: 25-March 09

Posted 06 April 2009 - 01:49 AM

Hello,
Yes I had a look, but the screens show an access to modules of the site (maybe it's an idea, I will think about it) and I need access to data.
What I don't like is that it doesn't fit in the actual design of RBAC lib, and is bloated with a lot of checkboxes.
What I like is that is everything in one place.
In the actual display model the easiest  way to do it is to have a set of tables with the structure of the application and dropdowns for each level of it. At the end we can add a field (another dropdown) which sets the level of access. (in fact can be a set of bizRules stored in db.
(my main problem now is how to make autosubmit in the permission form to refresh the controller list and actions depending on modules)
Thanks,
Paul

Edit:
1. maybe with the help of this plugin:
http://plugins.jquer...project/cascade

2. Still the checkbox tree doesn't display correctly in the Roles page. No idea why :(


0

#59 User is offline   Paul Apostol 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 61
  • Joined: 25-March 09

Posted 09 April 2009 - 01:51 PM

Hello,
I still didn't figure why the checktree doesn't work, I have a guess that "run" part of the extension doesn't run (i didn't found in the generated source the script defined there). I'll keep searching.
I've changed a bit the BaseAdminController to fit other data needs.
1. I added in actionUpdate, just befor the ajax check
$data = array_merge(array('model'=>$model, 'scenario'=>$scenario, 'modules'=>$modules), $this->extraData());

2. instead of
$output = $this->renderPartial('_form', array('model'=>$model, 'scenario'=>$scenario), true, false);

I have now
$output = $this->renderPartial('_form', $data, true, false);

3. I added a new function:
public function extraData(){ return array();}

and now, by overriding this function in the controller you can send more data to the view. As ex:
public function extraData()
    {
    $criteria=new CDbCriteria;
$modules=modules::model()->findAll($criteria);
return array('modules'=>$modules);
   
    }

Hope that helps,
Paul

PS: same for actionCreate

0

#60 User is offline   Paul Apostol 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 61
  • Joined: 25-March 09

Posted 09 April 2009 - 02:26 PM

Found the problem with the tree (I forgot to say that I'm using windows for development)
the problem is DIRECTORY_SEPARATOR
if we use
'/'
instead will be better for everybody. It's better for portability, anyway.
Paul
0

Share this topic:


  • (5 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • 5
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users