Skip to content

v0.6.2-stable

Latest
Compare
Choose a tag to compare
@AlexzPurewoko AlexzPurewoko released this 13 Mar 08:01
48f1cb8

What's Changed

Read the last PR for more details : [Improvements] Refactor the unset abilities by @AlexzPurewoko in #3

Summary :

  • Improving the algorithm when dealing with unset ability. Previously, the algorithm can remove only the specific rule. For now, it can remove multiple rules specified by the 'star' (whole) parameters on action, resource and field.
    Example Rule :

     #ID. RULE
       1. scope:resource/666:*
       2. scope:resource2/7:read
       3. scope:resource2/*:update
       4. scope2:resource/*:read
    

    We can delete the multiple rule by input the asterisk on resource, field and action.

    • Delete the whole resource and whole action in one scope. Just pass -> unsetAbility('*', '*', 'scope');. All rule except rule with ID 4 will be deleted.
    • Delete the whole resource but specific action. Just pass -> unsetAbility('update', '*', 'scope');. This will delete the rule with ID 3.
    • Delete the whole action in specific resource. Just pass -> unsetAbility('*', 'resource2', 'scope');. This will delete the rule with ID 3 and 4.
    • And more... (read on the last pull requests).
  • Unset ability can remove specific field from arrayable fields. Take an example for this rule -> scope:resource/[5,6,7,8]:read. We can remove the rule/item's field by :

    • Using specific field -> unsetAbility('read', 'resource', 'scope', 5);. So, the item 5 will be removed from existing rule, and for the item field (except 5) will be remain (exist). Result : scope:resource/[6,7,8]:read
    • Multiple specific field -> unsetAbility('read', 'resource', 'scope', [5, 7]);. So, the item 5 and 7 will be removed from existing rule, and for the item field (except 5 and 7) will be remain (exist). Result : scope:resource/[6,8]:read
    • Remove the corresponding rule -> unsetAbility('read', 'resource', 'scope', [5, 7, 6, 8]);. This will remove the rule from the list/storage.

Compare : v0.6.1-stable...v0.6.2-stable