summaryrefslogtreecommitdiffhomepage
path: root/libs/sgi-webuci
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-06-02 17:49:27 +0000
committerSteven Barth <steven@midlink.org>2008-06-02 17:49:27 +0000
commitf56890a5733b3c57d088b52bf91a77c44976ca99 (patch)
treee835d0e242cf957bc8b0d0cce1eb5551c3d4a321 /libs/sgi-webuci
parent92d76ed83603e50321f171996fc78cef0a6d3580 (diff)
* Added native basic authentication support
* Cleanups
Diffstat (limited to 'libs/sgi-webuci')
-rw-r--r--libs/sgi-webuci/luasrc/sgi/webuci.lua15
-rw-r--r--libs/sgi-webuci/root/usr/lib/boa/luci.lua2
2 files changed, 17 insertions, 0 deletions
diff --git a/libs/sgi-webuci/luasrc/sgi/webuci.lua b/libs/sgi-webuci/luasrc/sgi/webuci.lua
index 2beff6907..1ad067c6b 100644
--- a/libs/sgi-webuci/luasrc/sgi/webuci.lua
+++ b/libs/sgi-webuci/luasrc/sgi/webuci.lua
@@ -33,6 +33,21 @@ function initenv(env, vars)
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 ""
diff --git a/libs/sgi-webuci/root/usr/lib/boa/luci.lua b/libs/sgi-webuci/root/usr/lib/boa/luci.lua
index 2ea6ba4cb..e34bd5e2d 100644
--- a/libs/sgi-webuci/root/usr/lib/boa/luci.lua
+++ b/libs/sgi-webuci/root/usr/lib/boa/luci.lua
@@ -38,6 +38,8 @@ function init(path)
luci.sys.net.routes = function() return {} end
luci.sys.wifi.getiwconfig = function() return {} end
luci.sys.wifi.iwscan = function() return {} end
+
+ luci.sys.user.checkpasswd = function() return true end
end
end