Single database user
We used to have:- application user = database user
- application password = database password.
The upgrade neither creates nor deletes any database users. The code to do so is completely disabled in SuperOffice v.7. Database users and their settings and rights are the responsibility of the customer.
Sentry
What is sentry? As the name implies it acts as the watchdog or traffic cop that keeps an eye on all the access to data in the SuperOffice database. Each object in NetServer has an associated sentry that is responsible for enforcing rules such as “private appointments are visible only to its owner”. Sentry rules focus on ownership, group membership, and user-level access. Sentry is a shared component used by all SuperOffice code to evaluate access rights. The Sentry objects answer questions regarding which tables and fields are accessible to a given type of operation, but do not themselves enforce these rights - this is up to the various client objects. In SuperOffice the security is based on roles so all the user of SuperOffice belongs to a role. The different roles have different levels of rights to access the data in the database so Sentry is the mechanism that ensures that these levels get the proper data access. The levels of data access rights in SuperOffice are as follows.- None
- Read
- Create
- Update
- Delete
Sentries, main tables, and sub-tables
The Sentry system is responsible for evaluating access rules. It consists of a common base class, and a subclass for each main table there is a Sentry for. The main tables at the time of writing are:- contact
- person
- project
- appointment
- sale
- selection
- relation
Rights overrides may be applied to any table or field that is a main table or a sub-table of a main table.
Sentry in services
In the NetServer service layer, the sentry information is provided in 2 properties:FieldProperties
TheFieldProperties is the mechanism that is provided by NetServer to check the individual field access rights of the logged-in user. All the entities of the service layer will have this property.
A typical use of this property is to check the data rights of the user before making a change or before reading a value. We can use this property for many other purposes like to check the data rights and disable a certain button or a read-only field.
FieldRight
We can use several properties provided by theFieldRight property (of a field) to check for rights. The most commonly used ones are listed below.
The
Reason property will have a reason if the user does not have the full permission (Read, Create, Update, and Delete) however if the user has full permission the reason property will be blank.
TableRight
TheTableRight property focuses on the table as a whole. It has mechanisms to determine whether the logged-in user has the rights to the table.
A typical use of this property is as follows: imagine you have a full form of fields that are of contact information. If a particular user logging in does not have the right to change data, you can make all the fields disabled.
It’s easier to check the rights of the table than checking each field if you are trying to restrict updates to an entire table since it is easy checking the right of the table than checking each field by field.
If you let the user do some operation that the user does not have proper rights to, NetServer will throw errors so it is always good to check for data rights before we let a user do some operation.
TableRight exposes its value as a set of flags. We recommend creating an enum such as the one below (C#, adapt to your language of choice):