Skip to content

Authentication Modules

Authentication modules are pieces of code that allow Observium to use different sorts of user databases. They also take care of changing passwords (or disallowing it) and other related things. You can use any of the supplied ones to start from.

Please do send us a patch if you create something new! That way it will (hopefully) also be automatically updated if we add new interface functions.

Initialization

The modules are included upon every page load; if you need initialization code (connecting to an LDAP server, etc), you can place it outside of a function, the code will be run automagically.

If you write module-specific functions, please mark them as such in the source code so the difference between our auth "API" and local functions is clear. Please name them so they won't conflict with future Observium-internal functions!

Interface

Auth modules live in html/includes/authentication and should end in .inc.php. They need to have the following functions:

Authentication

function authenticate($username,$password)

Check the combination of username and password.

function auth_can_change_password($username = "")

Return 1 if the module can change user passwords, 0 if it cannot. The username is passed on as well, if your module supports locking certain users' passwords.

function auth_change_password($username,$password)

Change the user's password to a new value, if passwords can be changed.

function auth_can_logout()

Return TRUE if the module allows users to log out, FALSE if it doesn't.

User data

function auth_user_exists($username)

Check if this username exists.

function auth_user_level($username)

Return the user level of the specified user.

function auth_user_id($username)

Return the user id of the specified user.

function auth_user_list()

Returns a list of users in an array with the following keys: username, realname, user_id

User management

function auth_usermanagement()

Return 1 if the module can do user management, 0 if it cannot.

function adduser($username, $password, $level, $email = "", $realname = "", $can_modify_passwd = '1')

Add a user with the specified attributes, if user management is allowed.

function deluser($username)

Deletes the specified user, if user management is allowed.