We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32963
    • 1,732 Posts
    I’ve added binary access control level (acl) detection to documents which IMO should speed up retrieval of secure documents:

    * The acl of a document is the sum of the binary representation of all it’s document groups.
    * The binary representation of a document group is calculated as 2^id (2 raised to the power of the group’s id)
    * by using this method we’ll will able to determine with group the document belongs to by doing a bit-wise comparison
    * of it’s acl with the user’s acl
    *
    * example:
    * document 2 belongs to doc groups 1,2,3 which has a binrary value of 2,4 and 8 respectively
    * The acl of document 2 would be calculated as 14.
    * User A has access to doc groups 2 and 3. User A’s document acl would then be calculated as 12

    By comparing document 2’s acl and User A’s acl we can determine whether or not user A has access to document 2

    This also means that we don’t have to use DISTINCT keyword or include another table to get the document groups for the document. It’s all mathematically calculated.

    What do you guys think about this approach?


      xWisdom
      www.xwisdomhtml.com
      The fear of the Lord is the beginning of wisdom:
      MODx Co-Founder - Create and do more with less.
      • 25663 MODX Staff
      • 12,272 Posts
      I had a brief chat with Raymond and the comparissons are taking place in binary space. So the user (12) evals bitwise to:

      1100

      and the Document (14) to:

      1110

      The overlaping 1s means that the access would be granted.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 32963
        • 1,732 Posts
        There’s one little problem that I’ve detected with the ACL method is that MySQL only supports upto 63 to 64 bit calculation (bitwise). This means that the largest number we can work on is 9223372036854775808.

        The problem is when the id value increases so does the binary value. If MySQL stops at 64-bit then it means that we can only have a maximum of 64 Docgroups. Now that’s a problem!

        Does anyone know of another way we can calculate the ACL?

        This method is much faster than joining to tables and having to use the distinct keyword.
          xWisdom
          www.xwisdomhtml.com
          The fear of the Lord is the beginning of wisdom:
          MODx Co-Founder - Create and do more with less.