Changes between Initial Version and Version 1 of AccessControl


Ignore:
Timestamp:
08/27/09 12:32:32 (5 years ago)
Author:
rgrp
Comment:

detailed first sketch

Legend:

Unmodified
Added
Removed
Modified
  • AccessControl

    v1 v1  
     1= Access control = 
     2 
     3[[PageOutline]] 
     4 
     5== Use Cases == 
     6 
     7  * A user means someone who is logged in. 
     8  * A visitor means someone is not logged in. 
     9  * An entity is the subject of a permission (either a user or a pseudo-user) 
     10 
     111. A visitor visits a package page and reads the content 
     12 
     132. A visitor visits a package page and edits the package 
     14 
     153+4: Ditto for a user 
     16 
     175. On package creation if done by a user and not a visitor then user is made the 'admin' 
     18 
     196. An admin of a package adds a user as an admin 
     20 
     217. An admin of a package removes a user as an admin 
     22 
     238. Ditto for admin re. editor 
     24 
     259. Ditto for admin re. reader 
     26 
     2710. We wish to be able assign roles to 2 specific entire groups in addition to specific users: 'visitor', 'users'. These will be termed pseudo-users as we do not have AC 'groups' as such. 
     28 
     2911. The sysadmin alters the assignment of entities to roles for any package 
     30 
     3112. A visitor goes to a package where the editor role does not include 'visitor' pseudo-user. They are unable to edit the package. 
     32 
     3313. Ditto for user where users pseudo-user does not have editor role and user is not an editor for the package 
     34 
     3514+15: Ditto for above re reader role ... 
     36 
     37 
     38== Optional == 
     39 
     40  * Support for access-related groups 
     41  * Support for blacklisting 
     42 
     43 
     44== Implementation == 
     45 
     46{{{ 
     47    Context 
     48Entity ----> Roleckage | role | group 
     49--------------------------- 
     50xyz     | admin     | admin 
     51xyz     | edit      | anonymous 
     52xyz     | read      | anonmyous 
     53xyz     | purge     | editor 
     54 
     55 
     56    Context 
     57Role ----> Action/Permission/Capability (on an Object e.g. a Package) 
     58}}} 
     59 
     60 
     61Package level: 
     62 
     63  * Package Roles: admin, editor, readerckage | role | group 
     64--------------------------- 
     65xyz     | admin     | admin 
     66xyz     | edit      | anonymous 
     67xyz     | read      | anonmyous 
     68xyz     | purge     | editor 
     69 
     70  * Entities: [email protected] (user), pseudo-users 'visitor' 
     71  * Assignment of entities to roles in a given context (the package) 
     72  * Roles give permissions (in a given context) 
     73    * admin -> update assignment to roles, delete package, plus editor 
     74    * editor -> update package plus reader 
     75    * reader -> read package 
     76 
     77System level permissions: 
     78ckage | role | group 
     79--------------------------- 
     80xyz     | admin     | admin 
     81xyz     | edit      | anonymous 
     82xyz     | read      | anonmyous 
     83xyz     | purge     | editor 
     84 
     85  * Roles:?? 
     86  * create package  
     87  * update assignment of system level role 
     88 
     89=== Determining permissions === 
     90 
     91{{{ 
     92def is_allowed(name, action, context=None): 
     93    user = locate_user(name) 
     94    if not user: 
     95        # they are a visitor ... 
     96    
     97    if context is None: 
     98        context = 'system' 
     99    contextroles = locate_roles(user, context) 
     100    if context != 'system': 
     101        sysrole = 
     102        if sysrole = 'sysadmin': 
     103            # can do anything ... 
     104            return True 
     105    for role in contextroles:ckage | role | group 
     106--------------------------- 
     107xyz     | admin     | admin 
     108xyz     | edit      | anonymous 
     109xyz     | read      | anonmyous 
     110xyz     | purge     | editor 
     111 
     112        # assuming 'ORing' of permissions 
     113        if role.is_allowed(action) 
     114            return True 
     115    if visitor: 
     116        visitor_role = locate_roles(visitor, context) 
     117        # check again 
     118    return False 
     119}}} 
     120ckage | role | group 
     121--------------------------- 
     122xyz     | admin     | admin 
     123xyz     | edit      | anonymous 
     124xyz     | read      | anonmyous 
     125xyz     | purge     | editor 
     126 
     127=== Initializing Permissions for a Package === 
     128 
     129 when we create a package: visitor is given reader and editor roles automatically (ditto for user) 
     130 
     131=== DB Sketch === 
     132 
     133{{{ 
     134role-table 
     135 
     136name | context | action 
     137admin| package | update 
     138admin| package | update-permissions 
     139admin| package | read 
     140editor| package | update 
     141editor| package | read 
     142 
     143user-role-table 
     144 
     145username | context_type | objectid | role 
     146xyz      | package | geonames | admin 
     147rgrp     | system  |   | admin 
     148visitor  | package |   | reader 
     149visitor  | package | geonames  | editor  
     150visitor  | package | geonames | reader 
     151 
     152}}}