--[[
-LuCI - SGI-Module for Haserl
+LuCI - SGI-Module for Webuci
Description:
-Server Gateway Interface for Haserl
+Server Gateway Interface for Webuci
FileId:
$Id: webuci.lua 2027 2008-05-07 21:16:35Z Cyrus $
luci.http.vars = vars
end
+-- Enforces user authentification
+function luci.http.basic_auth(verify_callback, realm)
+ local user = luci.http.env.auth_user
+ local pass = luci.http.env.auth_password
+ realm = realm or ""
+
+ if not user or not verify_callback(user, pass) then
+ luci.http.status("401", "Unauthorized")
+ luci.http.header("WWW-Authenticate", string.format('Basic realm="%s"', realm))
+ return false
+ else
+ return true
+ end
+end
+
-- Returns the main dispatcher URL
function luci.http.dispatcher()
return luci.http.env.SCRIPT_NAME or ""