Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Problem with ORM Auth User Permissions
  • Hi there,

    I'm usign the ORMAuth and setting permissions to a specific user using the table *_user_permissions. But when the acl driver generate the permissions to the user, it override the actions of the permissions.

    An Example: I set up this permission control.user.[list, add] and this control.banner.[edit, delete], but when the acl driver generate the cache, it generate this: control.user.[list,add] and this control.banner.[list, add].


  • HarroHarro
    Accepted Answer
    That is because it doesn't work that way.

    The permission record contains an indexed array with ALL possible actions for that permission,
    so [0 => list,1 => add, 2 => edit, 3=> delete].

    The permission join record will then contain the indexes of the selected actions for that specific join record, for example [0,1] for [list,add], and [2,3] for [edit,delete].

    See http://fuelphp.com/forums/discussion/12690/users-and-permissions
  • I tried this, but apparently still the same.

    Here are some database records:

    *_permissions

    1 | control | user | User | a:3:{i:0;s:4:"list";i:1;s:3:"add";i:2;s:4:"edit";} | 2 | 0 | 0

    2 | control | banner | Banner | a:3:{i:0;s:4:"list";i:1;s:3:"add";i:2;s:4:"edit";} | 2 | 0 | 0

    *_user_permission

    11 | 8 | 1 | a:2:{i:0;s:1:"0";i:1;s:1:"1";}

    12 | 8 | 2 | a:1:{i:0;s:1:"0";}

    But the cache file still wrong
    {{Fuel_Cache_Properties}}{"created":1386673102,"expiration":null,"dependencies":[],"content_handler":"serialized"}{{/Fuel_Cache_Properties}}a:3:{i:0;a:1:{s:7:"control";a:2:{s:4:"user";a:2:{i:0;s:4:"list";i:1;s:3:"add";}s:6:"banner";a:2:{i:0;s:4:"list";i:1;s:3:"add";}}}i:1;a:0:{}i:2;N;}
  • Which Fuel version are you on? Sure the Auth package has the same version?
  • I'm using the FuelPHP v1.7.1
  • I'm running 1.8/develop, which is virtually the same as 1.7.1, and I haven't seen this behaviour.

    I'll try to setup some tests, this is specific about permissions directly assigned to a specific user? Or do you have the same issue if you assign permissions to a user via group or role membership (the join table for those works exactly the same)?
  • Only in specific permissions, for group permissions it is working.
  • Hmm... I'll run some tests...
  • Hi, any news?

    Thank you.
  • haven't had time for it yet, I'm travelling. I'll try to squeeze it in next week.
  • I've setup a test here using our own app framework (for which Ormauth was written), running 1.8/develop.

    When I create a user, and assign him the exact same rights you mentioned above (and select the "list" action for "banner", and the "add" and "edit" actions for user), I get this in the cache, which looks right to me.

    {{Fuel_Cache_Properties}}{"created":1387563666,"expiration":1387564266,"dependencies":[],"content_handler":"serialized"}{{/Fuel_Cache_Properties}}a:3:{i:0;a:1:{s:6:"control";a:2:{s:6:"banner";a:1:{i:0;s:4:"list";}s:4:"user";a:2:{i:0;s:3:"add";i:1;s:4:"edit";}}}i:1;a:0:{}i:2;N;}
  • Just updated the rights with user[list,add] and banner[list], and now the cache is:

    {{Fuel_Cache_Properties}}{"created":1387563984,"expiration":1387564584,"dependencies":[],"content_handler":"serialized"}{{/Fuel_Cache_Properties}}a:3:{i:0;a:1:{s:5:"admin";a:2:{s:6:"banner";a:1:{i:0;s:4:"list";}s:4:"user";a:2:{i:0;s:4:"list";i:1;s:3:"add";}}}i:1;a:0:{}i:2;N;}

    which still looks fine to me.
  • Thank you for your attention.
    I will try to update the fuelphp and auth package to see if the problem will fix or maybe I`m doing something wrong, I will take a look.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion