Commit 3a4e084c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Lua http: add a configurable password

This is way more flexible than ACL:
 - does not need admin rights to edit,
 - does not assume the clients have fixed IP addresses,
 - does not assume the clients are single user systems,
 - is a better understood concept than access control lists.
parent 339ef8e2
......@@ -50,6 +50,9 @@
#define CONFIG_TEXT N_("Lua interface configuration")
#define CONFIG_LONGTEXT N_("Lua interface configuration string. Format is: '[\"<interface module name>\"] = { <option> = <value>, ...}, ...'.")
#define PASS_TEXT N_( "Password" )
#define PASS_LONGTEXT N_( "A single password restricts access " \
"to this interface." )
#define SRC_TEXT N_( "Source directory" )
#define SRC_LONGTEXT N_( "Source directory" )
#define INDEX_TEXT N_( "Directory index" )
......@@ -91,6 +94,7 @@ vlc_module_begin ()
add_submodule ()
set_section( N_("Lua HTTP"), 0 )
add_password ( "http-password", NULL, PASS_TEXT, PASS_LONGTEXT, false )
add_string ( "http-src", NULL, SRC_TEXT, SRC_LONGTEXT, true )
add_bool ( "http-index", false, INDEX_TEXT, INDEX_LONGTEXT, true )
set_capability( "interface", 0 )
......
......@@ -134,7 +134,7 @@ function dirlisting(url,listing,acl_)
</body>
</html>]]
end
return h:file(url,"text/html",nil,nil,acl_,callback,nil)
return h:file(url,"text/html",nil,password,acl_,callback,nil)
end
-- FIXME: Experimental art support. Needs some cleaning up.
......@@ -207,7 +207,7 @@ function file(h,path,url,acl_,mime)
end
return table.concat(page)
end
return h:file(url or path,mime,nil,nil,acl_,callback,nil)
return h:file(url or path,mime,nil,password,acl_,callback,nil)
end
function rawfile(h,path,url,acl_)
......@@ -228,7 +228,7 @@ function rawfile(h,path,url,acl_)
end
return page
end
return h:file(url or path,nil,nil,nil,acl_,callback,nil)
return h:file(url or path,nil,nil,password,acl_,callback,nil)
end
function parse_url_request(request)
......@@ -329,6 +329,7 @@ if config.host then
vlc.msg.info("Pass --http-host=IP "..(port and "and --http-port="..port.." " or "").."on the command line instead.")
end
password = vlc.var.inherit(nil,"http-password")
h = vlc.httpd()
local root_acl = load_dir( http_dir )
local a = h:handler("/art",nil,nil,root_acl,callback_art,nil)
local a = h:handler("/art",nil,password,root_acl,callback_art,nil)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment