Cakephp 2.0 row/record-level Acl

前端 未结 1 669
遥遥无期
遥遥无期 2021-01-16 12:17

i am messing around with the cakephp 2.0\'s access lists, so far i created a very simple example following the documentation.

I have set up a users table and the mos

相关标签:
1条回答
  • 2021-01-16 13:07

    Based on your aro_aco table, it looks like this is correct behavior. User.4 belongs to the admins group which has update permission. set to true in row 8. You have a rule in row 8 specifically for User.4, but you have granted update permission specifically to that user in that row. It appears that the ACL rules are working exactly as you have them setup. To prevent User.4 from using the update permission, run this at the cake command line to update your rules for User.4:

    cake acl deny User.4 House.1 update
    

    It should then return false when you run a check:

    cake acl check User.4 House.1 update
    

    EDIT

    I'm going to attempt to revise this based on comments left below. I think that you may still be setting up the rules incorrectly. I am going to use the command line examples (because it's either to both type and to do in practice) but you can just as easily write the PHP to do this. My examples below also focus on admin, but you could use for the superadmin and users groups too.

    First, deny everything to admins since we want to grant permissions individually:

    cake acl deny admin Houses all
    

    Then, grant the read only permission to admin so they can all read Houses:

    cake acl grant admin Houses read
    

    Lastly, grant the update permission to the specific user that gets update privileges:

    cake acl grant User.4 Houses.1 update
    

    These permissions should allow User.4 to read and update the House record. Keep in mind that if you have already created deny or allow records for User.4 then this example may not work. You may want to truncate your aco_aro table and start over since it's small at this point.

    If all acl checks work, but the behavior is still incorrect, then you may have an issue with how the ACL component is authorizing an action. You may have to tweak those settings in $beforeFilter or your $components array.

    0 讨论(0)
提交回复
热议问题