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 @@ ...@@ -50,6 +50,9 @@
#define CONFIG_TEXT N_("Lua interface configuration") #define CONFIG_TEXT N_("Lua interface configuration")
#define CONFIG_LONGTEXT N_("Lua interface configuration string. Format is: '[\"<interface module name>\"] = { <option> = <value>, ...}, ...'.") #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_TEXT N_( "Source directory" )
#define SRC_LONGTEXT N_( "Source directory" ) #define SRC_LONGTEXT N_( "Source directory" )
#define INDEX_TEXT N_( "Directory index" ) #define INDEX_TEXT N_( "Directory index" )
...@@ -91,6 +94,7 @@ vlc_module_begin () ...@@ -91,6 +94,7 @@ vlc_module_begin ()
add_submodule () add_submodule ()
set_section( N_("Lua HTTP"), 0 ) 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_string ( "http-src", NULL, SRC_TEXT, SRC_LONGTEXT, true )
add_bool ( "http-index", false, INDEX_TEXT, INDEX_LONGTEXT, true ) add_bool ( "http-index", false, INDEX_TEXT, INDEX_LONGTEXT, true )
set_capability( "interface", 0 ) set_capability( "interface", 0 )
......
...@@ -134,7 +134,7 @@ function dirlisting(url,listing,acl_) ...@@ -134,7 +134,7 @@ function dirlisting(url,listing,acl_)
</body> </body>
</html>]] </html>]]
end end
return h:file(url,"text/html",nil,nil,acl_,callback,nil) return h:file(url,"text/html",nil,password,acl_,callback,nil)
end end
-- FIXME: Experimental art support. Needs some cleaning up. -- FIXME: Experimental art support. Needs some cleaning up.
...@@ -207,7 +207,7 @@ function file(h,path,url,acl_,mime) ...@@ -207,7 +207,7 @@ function file(h,path,url,acl_,mime)
end end
return table.concat(page) return table.concat(page)
end 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 end
function rawfile(h,path,url,acl_) function rawfile(h,path,url,acl_)
...@@ -228,7 +228,7 @@ function rawfile(h,path,url,acl_) ...@@ -228,7 +228,7 @@ function rawfile(h,path,url,acl_)
end end
return page return page
end 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 end
function parse_url_request(request) function parse_url_request(request)
...@@ -329,6 +329,7 @@ if config.host then ...@@ -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.") vlc.msg.info("Pass --http-host=IP "..(port and "and --http-port="..port.." " or "").."on the command line instead.")
end end
password = vlc.var.inherit(nil,"http-password")
h = vlc.httpd() h = vlc.httpd()
local root_acl = load_dir( http_dir ) 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