Lua Server Pages - Authentication
LSP authentication and authorization is implemented using the Barracuda
server library code. Hence the server documentation is largely applicable to LSP.
The authentication of a LSP application is
initiated by providing a ".preload" file in the root of the application
directory. The ".preload" file is executed when the Barracuda server starts and
and can configure authentication/authorization via a single Lua function call.
The ".preload" file provides one additional (only available in .preload files)
function call set_authenticate(), this
function allows you to specify LSP functions that will be called for authorization and authentication,
it also allows you specify responses that will be supplied for a login page or
when a login fails.
--
-- Authorization example
--
-- Install this as a .preload file
--
-- To use LSP authorization a set of auth functions must be
-- specified:
--
-- 1. For authentication (does this user exist)
-- function(username)
-- returns password [,maxusers [, recycle, timeoutinterval]]
--
-- 2. For Authorization
-- function()
-- function (user, method, path)
-- returns true or false
--
-- Note that these function are executed in the context of the global
-- environment.
--
set_authenticate(
-- the authentication function
function(user)
-- allow any user wher the password is the same as the user
return user -- return the password
end,
-- the authorizing function
function (user, method, path, apptable)
-- always authorize
return true
end,
-- the following optional strings can be used to enable/disable form
-- authentication
{
loginpage="/loginbody.shtml",
errorpage="/errorpage.lsp",
authtype="digest",
}
);