HOW TO : CORE
The authorization process is based
on the database schema you can find at here and the
authorization logic must be implemented in the main project action.
Let's now see the classes offered by the framework for authorizing a user to use an action.
To check if a user can use an action, all you have to do is to use this class as in the next example:
The method authorize
returns an integer that can have one of the next values:
- AUTHORIZED_NO: user can not execute the service.
- AUTHORIZED_YES: user can execute the service.
- AUTHORIZE_ALL: all users can execute the service.
- AUTHORIZE_AUTHENTICATED: all authenticated users can execute the service.
- SERVICE_NOT_FOUND: service name not exist in database
in table SERVICE.
The return value is based on the return values of classes
You can use the return value as you prefer in the implementation of method
in your main action
This class is used for checking if the service is registered in table SERVICE
and for getting his data. For the
authorization process the value of column SERVICE.service_free
is the most important. The previous column can have these values:
this value indicates that all users, even if they are not authenticated, can use the action.
only authenticated users can use the action.
only authenticated users can use the action and an entry in table must exist
This class is used to check if a particular user can execute a particular action.
Here is an example of use: