Index: openacs-4/packages/acs-core-docs/www/permissions-tediously-explained.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/permissions-tediously-explained.html,v diff -u -r1.16 -r1.17 --- openacs-4/packages/acs-core-docs/www/permissions-tediously-explained.html 11 Nov 2003 12:54:57 -0000 1.16 +++ openacs-4/packages/acs-core-docs/www/permissions-tediously-explained.html 19 Nov 2003 15:44:51 -0000 1.17 @@ -1,6 +1,6 @@ -
+
by Vadim Nasardinov. Modified and converted to Docbook XML by Roberto Mello -
+
The code has been modified since this document was written so it is now obsolete. See this forum thread.
The general permissions system has a relatively complex data model in OpenACS 4.x. Developers who haven't had the time to learn the internals of the data model may end up writing seemingly correct code that crashes their system in @@ -85,7 +85,7 @@ to store permission information explicitly about every object, i.e. if the system has 100,000 and 1,000 users who have the read privilege on all objects, then we would need to store 100,000,000 entries of the form: -
Table�8.1.�
object_id | grantee_id | privilege |
---|---|---|
object_id_1 | user_id_1 | 'read' |
object_id_1 | user_id_2 | 'read' |
... | ||
object_id_1 | user_id_n | 'read' |
object_id_2 | user_id_1 | 'read' |
object_id_2 | user_id_2 | 'read' |
... | ||
object_id_2 | user_id_n | 'read' |
... | ||
... | ||
object_id_m | user_id_1 | 'read' |
object_id_m | user_id_2 | 'read' |
... | ||
object_id_m | user_id_n | 'read' |
+
object_id | grantee_id | privilege |
---|---|---|
object_id_1 | user_id_1 | 'read' |
object_id_1 | user_id_2 | 'read' |
... | ||
object_id_1 | user_id_n | 'read' |
object_id_2 | user_id_1 | 'read' |
object_id_2 | user_id_2 | 'read' |
... | ||
object_id_2 | user_id_n | 'read' |
... | ||
... | ||
object_id_m | user_id_1 | 'read' |
object_id_m | user_id_2 | 'read' |
... | ||
object_id_m | user_id_n | 'read' |
Although quite feasible, this approach fails to take advantage of the fact that objects in the system are commonly organized hierarchally, and permissions usually follow the hierarchical structure, so that if user @@ -100,7 +100,7 @@
Suppose objects A, B, ..., and F form the following hierarchy. -
Table�8.2.�
A + Table�8.1.�Context Hierarchy Example
- This can be represented in the - acs_objects table + This can be represented in the + acs_objects table by the following entries: - + The first entry tells us that object 20 is the descendant of object 10, and the third entry shows that object 40 is the descendant of object 20. By running a CONNECT BY query, we can compute that object 40 is the second-generation descendant of object 10. With this in mind, if we want to record the fact that user Joe has the read privilege on objects A, ..., F, we only need to record one entry in the - acs_permissions table. - + acs_permissions table. +
The fact that Joe can also read B, C, ..., and F can be derived by ascertaining that these objects are children of A by traversing the context hierarchy. As it turns out, hierarchical queries are expensive. As Rafael Schloming put it so aptly, Oracle can't deal with hierarchies for shit. One way to solve this problem is to cache a flattened view of the context tree like so: - +
Note that the number of entries in the flattened view grows exponentially with respect to the depth of the context tree. For instance, if you have a fully populated binary tree with a depth of n, then the number of entries @@ -147,10 +147,10 @@ create table acs_object_context_index ( object_id not null - constraint acs_obj_context_idx_obj_id_fk references acs_objects(object_id), + constraint acs_obj_context_idx_obj_id_fk references acs_objects (object_id), ancestor_id not null - constraint acs_obj_context_idx_anc_id_fk references acs_objects(object_id), + constraint acs_obj_context_idx_anc_id_fk references acs_objects (object_id), n_generations integer not null constraint acs_obj_context_idx_n_gen_ck check (n_generations >= 0), @@ -168,7 +168,7 @@ with respect to the depth of the context tree. The acs_object_context_index is kept in sync with the - acs_objects + acs_objects table by triggers like this: create or replace trigger acs_objects_context_id_in_tr @@ -198,12 +198,12 @@ end if; end; - One final note about - acs_objects. By setting + One final note about + acs_objects. By setting an object's security_inherit_p column to 'f', you can stop permissions from cascading down the context tree. In the following example, Joe does not have the read permissions on C and F. - Table�8.6.�
|