Authenticator

Description

Configurable module that provides login and related functionality.

This module is thought to run as server-side code, and operated by another specific, custom piece of server code, we extensively refer to in this document as client code.

This module must NOT be directly targeted nor requested by a web browser.

Features list

* these two behaviours are mutually exclusive due to security reasons. Once a master has opted-in for password reset instead of password recovery, he cannot opt out; passwords won't be recoverable from that point onward, merely resetable.

Authenticate

The module is totally agnostic of anything. It does not even “know” whether a session is currently “alive” on a certain machine. It merely provides the act of authentication and authentication alone. Therefore, you must invoke it on each and every request, and re-authenticate from a request to another. There are three patterns of authentication supported.

IN

OUT

Success

Failure

Username and Password *

Unique session id

Error number

Username and MD5 hash of password **

Unique session id

Error number

Unique session id

New unique session id

Error number

* only available if password recovery support hasn't been dropped.

** only available if password recovery support has been dropped.

Based on whether you are returned a unique session id or an error number, client code must decide whether to consider the user authenticated and provide him with the protected content, or not.

Note: MD5 hashes in the input data are there to support the ability of MD5 hashing some client side scripting languages have. If user provided MD5 of password at registration time, he must always provide MD5 instead of plain pass.

(Self-)register

This module provides support for open registration. This support can be dropped at master's choice. For security reasons, once the open registration support has been dropped, it cannot be enabled again. The following table describes the data exchange between the client code and this module, during the registration process.

This module also provides optional support for a security question and answer. This support can be dropped at master's choice. For security reasons, once the security question support has been dropped, it cannot be enabled again.

IN

OUT

Success

Failure

Security question OFF

User Email and Username and Password*

Confirmation unique id***

Error number

User Email and Username and MD5 hash of password**

Confirmation unique id***

Error number

Security question ON

User Email and Username and Password and Security Question and Security Answer*

Confirmation unique id***

Error number

User Email and Username and MD5 hash of password and Security Question and MD5 hash of security answer**

Confirmation unique id***

Error number

Confirmation unique id

Unique session id****

Error number

* only available if password recovery support hasn't been dropped.

** only available if password recovery support has been dropped.

*** the client code is responsible for sending the confirmation unique id to the user, via e-mail, in order to proof that user actually owns that e-mail box.

**** the returned unique session id can be used for authentication (see authenticate).

Note: user name, user e-mail, user password (optionally security question and answer) AND super-user password, this is the only alternative left if open registration support has been dropped.

Password change

This module provides support for a user to change his current password. The following table describes the data exchange between client code and this module, during the password change process.

IN

OUT

Success

Failure

Username and current Password and new Password*

Unique session id***

Error number

Username and MD5 hash of current password and MD5 hash of new password**

Unique session id***

Error number

* only available if password recovery support hasn't been dropped.

** only available if password recovery support has been dropped.

*** the returned unique session id can be used for authentication (see authenticate).

Password recovery OR reset

This module provides support for password recovery OR reset. Since the password recovery behaviour involves storing the user password as plain text in the database, it is strongly discouraged. On the other hand, not storing the user password as plain text in the database effectively implies password reset as the unique alternative to a forgotten password. The master has to choose either to use the password recovery behaviour (default, slightly insecure for users but perhaps more convenient) or to entirely drop it in favour of the password reset behaviour (more secure but perhaps less convenient). Due to security as well as technical constraints, once the password recovery support has been dropped, it cannot be restored. The module is left with the password reset behaviour for the time being.

The following table describes the data exchange between client code and this module, during the password recovery OR reset processes.

IN

OUT

Security question OFF

User Email

Success

Failure

Password*

Error number

Generated** Password

Error number

Security question ON

User Email

Security Question

Error number

User Email and Security Answer*

Password*

Error number

User Email and MD5 hash of security answer**

Username and generated password**

Error number

* only available if password recovery support hasn't been dropped.

** only available if password recovery support has been dropped.

The client code is responsible for sending the results of the recover or reset operations to the user, via e-mail.

Setup

A list of configurable parameters for the module follows.

PARAMETER NAME

POSSIBLE VALUES

COMMENTS

sessionLifetime

-300 to 86`400 (seconds) or -1

If user makes no new request within this time frame, current session will automatically be closed. “-1” stands for infinite lifetime.

confirmationUidLifetime

86400 to 2678400 (seconds)

If open registration support hasn't been dropped, this governs the time frame the generated unique confirmation id must be returned within, in order for self-registration to be validated. Defaults to one day (or 86400 seconds)

blacklistTimeout

60 to 3600 (seconds) or -1

Clock will start ticking from first failed login attempt an IP has made. If the IP consecutively provides maxAttempts th times bad credentials, and it does it during the blacklistTimeout period, that IP will be locked out for banTime, unless the master unlocks it in.


“-1” for the blacklistTimeout parameter will disable the timeout period. Bad logins ever made by a certain IP will cumulate, until a successful login resets them.


“-1” for the maxAttempts parameter entirely disables the feature.


“-1” for the banTime parameter will disable the block period, thus locking out an IP forever, unless a master unlocks it in.

maxAttempts

3 to 600 or -1

banTime

1800 to 86 400 (seconds) or -1

removeSecurityQuestionSupport

The "I am aware this is irreversible" phrase, in THIS case.

Setting this parameter will irrevocably bring into effect its associated behavior: users will no longer be required to provide a security question-and-answer pair in the process of open registration or forgotten password; existing security questions and their answers will be permanently deleted.


If open registration support was dropped, this parameter is ignored.

removePasswordRecoveryMode

The "I am aware this is irreversible" phrase, in THIS case.

Setting this parameter will irrevocably bring into effect its associated behaviour: plain passwords stored in the database will be encrypted; users will no longer be able to recover their passwords; instead, their forgotten passwords will be reset to some randomly generated string they will be invited to change.

removeOpenRegistrationSupport

The "I am aware this is irreversible" phrase, in THIS case.

Setting this parameter will irrevocably bring into effect its associated behaviour: users will no longer be able to register themselves into the system, instead, a master will have to manually add each user.

defaultRole

“[some string]”

If open registration support is available, this will set the role of new users registering themselves into the system. For security reasons, this string cannot be “administrator”, nor “master”. Defaults to "user".

API

/** 
 * @see "Authenticate" section
 */
authenticate  (credentials, userName=null, userRole=null);

/**
 * Erases the provided unique session id from the database.
 */
unAuthenticate  (uniqueSessionId);

/**
 * @see "(Self-)register section.
 * Credentials is a name-indexed array, supporting the following keys:
 * PASSWORD, SECURITY_QUESTION, SECURITY_ANSWER, SUPER_USER_PASSWORD,
 * CONFIRMATION_UID in this casing. PASSWORD and MASTER_PASSWORD will
 * also accept a MD5 HASH of a given password.
 * User role is optional and defaults to the value setup in the XML  conf.
 * file. User role cannot be given as "master",  although it is assumed to
 * be "master" for exactly one  self registration, when master is not set
 * yet.
 */
register  (credentials, userName=null, userEmail=null userRole=null);

/**
 * @see "Password Change" section.
 * As with the above, currentPassword and newPassword also accept MD5
 * hashes.
 */
changePassword  (userName, currentPassword, newPassword);

/**
 * @see "Password recovery OR reset" section. As with the  above, security
 * answer also accepts a corresponding MD5 hash. 
 */
retrievePassword  (userEmail, securityAnswer=null);

/**
 *  @see "Auto-block timeout" and friends in the "Setup"  table.
 */
unblockIp  (ip, masterPassword);

Return codes

Known Limitations, Gotchas