|Version 5 (modified by 10 years ago) ( diff ),|
Access Control & Permissions
There are a number of different security policies available to allow either a simple system or else provide advanced functionality:
- S3AAA - Sahana's Access Control system
The default security policy has most data available to Read by anonymous users & Edit/Delete by registered users.
Registered Users are added to Roles.
- The 1st registered user gets the 'Administrator' role (id 1) by default
- All registered users get the 'Authenticated' role (id 2) by default
Control access to a Module
If all you need to do is to limit access to the controllers within 1 module, then this can be done whilst staying in the simple security policy.
You can configure options in the modules configuration in
- Add an
access = "|x|",line to the relevant module section.
- 'x' is the ID of the role that should be allowed access to the module
- This both hides the menu item & blocks access to the whole /module/ hierarchy.
Control access to Functions & Tables
You need to go up to security level 4, or above, in your
settings.security.policy = 3 # Apply Controller ACLs
settings.security.policy = 4 # Apply both Controller and Function ACLs
You then need to populate specific access permissions in the
s3_permission table in the database.
- If there are no permissions defined for any user for a resource, then access is unrestricted.
- If a permission is defined for any user then all other users have no access at all unless explicitly granted (Users with the Administrator role are exempt - they always have access).
- These permissions would normally be set via PrePopulate but there is a powerful API available to add/modify roles via CLI scripts & it is also possible to do it by directly modifying the database.
In order for these checks to be done, then you need to set that module as
restricted=True in your
Control access to Tables
If you want to control access to the data in a table, no matter by which controller it is accessed, then you need to go up to security level 5, or above, in your
settings.security.policy = 5 # Apply Controller, Function and Table ACLs
Note: Controllers which don't use the S3 framework can bypass this security, so you should not develop such custom controllers where you need to keep the data secure.
Control access to Records
Records can be owned by individuals or Organisations (including Branches, Teams & Facilities).
This allows control of access by Realm - so staff of 1 Organisation can see their records of a certain type yet not those for another Organisation in the same database.
You need to go up to security level 6, or above, in your
settings.security.policy = 6: Apply Controller, Function, Table ACLs and Entity Realm
This functionality can be extended to support Hierarchy so that data restrcited to a single organisation can be amde avaialble to all branches of that Organisation (however data owned by the Branch is by default only visible to members of the Branch):
settings.security.policy = 7: Apply Controller, Function, Table ACLs and Entity Realm + Hierarchy
This functionality can be extended yet further by allowing organisations to share their private data with selected individuals, teams, facilities and organisations that they wish to (this is done by delegating the access role to that other entity, as they can now decide which of their people get the access):
settings.security.policy = 8: Apply Controller, Function, Table ACLs, Entity Realm + Hierarchy and Delegations
Record Approval is currently being developed to limit access until approved, in addition to all the other options.