Stoc |
---|
Listed below are This chapter presents some typical security implementations in Servoy applications.
Stoc |
---|
Practical where the security will be managed by the developer of the application and does not require anyone else configuring users or permissions.
Steps
mustAuthenticate
flag to true (selected) for of the solution.To allow tenant administrators or "'super users" ' to adminstrate administrate users, or if you are when using an external authentication source, you must create custom authentication is required.
Custom authentication will allow the allows the developer to use a users table in the database for authentication or access an external authentication directory.
...
Info | ||
---|---|---|
| ||
When first introduced in Servoy, this method of using Login and Authenticator solutions was referred to as Enhanced Security. If you are When looking for any references to this method in other resources (such as the Servoy Forum), you may try searching for 'Enhanced Security'. |
For almost every implementation of security, the solution should have an onOpen method assigned. This event is triggered right after the authentication process is complete. Some of the functions of this method in regards to security include:
...
The code below is an example of a typical custom login method. In this scenario, the login page contains the following form variables:
...
The tenant is verified during login before actual authentication occurs.
Code Block |
---|
function login(){
errorMessage = null;
if(!userName){
errorMessage = 'Please specify a user name';
return false;
}
if(!password){
errorMessage = 'Please specify a password';
return false;
}
var tenantID = security.authenticate("myAuthenticator","getTenant",[userName]);
if(tenantID){
if(security.authenticate("myAuthenticator","loginUser",[userName,password])){
return true;
} else {
errorMessage = "No tenant found. Please check your password";
}
}
errorMessage = 'Login Failed';
}
|
...
The code below is an example of a typical authentication method.
Code Block |
---|
function loginUser(user, password) { if (!(user && password)) { application.output('Unexpected credentials received', LOGGINGLEVEL.DEBUG); return false; } var authenticated = ... //either query database or use LDAP if (authenticated) { var ok = security.login(user, user, ['group']) // Assume a group for each department application.output('User ' + user + ' authenticated: ' + ok, LOGGINGLEVEL.DEBUG); return ok; } application.output('User ' + user + ' could not be authenticated', LOGGINGLEVEL.DEBUG); // Sleep for 3 seconds to discourage brute force attacks application.sleep(3000); return false; } |
When authentication fails, adding a pauze can be useful to discourage brute force password attacks.
Note that you have the choice of querying there is the option to query the database or getting get an external authentication. You may also read a A user groups table might be read to create the array of groups the user has privledges privileges with. Also not note that the only thing that is returned is a true or false and that reporting errors to the user does not occur at the authenticator authentication level.
In a fully custom security implementation, both authentication and authorization information is handled outside of Servoy built in security paradigm.
...
The developer writes code to assign form and table security to each part of the solution. This style of solution is normally managed by exclusion: instead of assigning permission to every part, just assign permissions to the part you want controlled. An example of this working fully custom security can be found on the ServoyForge site in the Security framework.