Helma logo
helma.org » Home > Stories > authenticate()

authenticate()

Authenticates a user against a standard Unix password file.

Using the standard Unix crypt library, this function provides a secure and still easy way to authenticate users.

Syntax
authenticate(usernameString, passwordString)

Example
var login = authenticate("user", "pass");
if (login)
   res.write("Welcome back!");
else
   res.write("Oops, please try again...");

Welcome back!


The password file can be managed using the htpasswd utility which is included in the Apache web server distribution.

The function just returns true or false depending on whether the user was successfully authenticated. So you have to make sure to store the result in the session.data object by setting some cache flag.

The function compares the two arguments with the data in the file called "passwd" stored in the Helma installation directory. This can be overridden by a file with the same name in the application directory.

Please note that this function is currently not working under Windows because the Windows version of Apache's htpasswd can use a special type of MD5 encryption only.


... comment


Page last modified on 2002-07-16 11:41 by tobi