From 7c943a1d6bcf449019ca8a43e800e51f269bb8f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Mon, 14 Dec 2020 13:11:08 +0100 Subject: [PATCH] luci-mod-system: allow configuration of HTTPS redirection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a posibility for easy configuration of HTTPS redirection in uHTTPd. References: https://lists.infradead.org/pipermail/openwrt-devel/2020-December/032718.html Signed-off-by: Petr Štetiar --- .../resources/view/system/uhttpd.js | 22 +++++++++++++++++++ .../share/luci/menu.d/luci-mod-system.json | 14 ++++++++++++ .../usr/share/rpcd/acl.d/luci-mod-system.json | 14 ++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 modules/luci-mod-system/htdocs/luci-static/resources/view/system/uhttpd.js diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/uhttpd.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/uhttpd.js new file mode 100644 index 0000000000..d02e18505a --- /dev/null +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/uhttpd.js @@ -0,0 +1,22 @@ +'use strict'; +'require view'; +'require form'; + +return view.extend({ + render: function() { + var m, s, o; + + m = new form.Map('uhttpd', _('HTTP(S) Access'), _('uHTTPd offers HTTP or HTTPS network access.')); + + s = m.section(form.NamedSection, 'main', 'uhttpd', _('Settings')); + s.addremove = false; + + o = s.option(form.Flag, 'redirect_https', _('Redirect to HTTPS'), _('Enable automatic redirection of HTTP requests to HTTPS port.')); + o.enabled = 'on'; + o.disabled = 'off'; + o.default = o.disabled; + o.rmempty = false; + + return m.render(); + } +}); diff --git a/modules/luci-mod-system/root/usr/share/luci/menu.d/luci-mod-system.json b/modules/luci-mod-system/root/usr/share/luci/menu.d/luci-mod-system.json index 4022e0cebf..ebae989d0e 100644 --- a/modules/luci-mod-system/root/usr/share/luci/menu.d/luci-mod-system.json +++ b/modules/luci-mod-system/root/usr/share/luci/menu.d/luci-mod-system.json @@ -60,6 +60,20 @@ } }, + "admin/system/admin/uhttpd": { + "title": "HTTP(S) Access", + "order": 4, + "action": { + "type": "view", + "path": "system/uhttpd" + }, + "depends": { + "acl": [ "luci-mod-system-uhttpd" ], + "fs": { "/usr/sbin/uhttpd": "executable" } + } + }, + + "admin/system/startup": { "title": "Startup", "order": 45, diff --git a/modules/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json b/modules/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json index e04bcdb476..9acb6e4471 100644 --- a/modules/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json +++ b/modules/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json @@ -38,6 +38,20 @@ } }, + "luci-mod-system-uhttpd": { + "description": "Grant access to uHTTPd configuration", + "read": { + "uci": [ "uhttpd" ] + }, + "write": { + "ubus": { + "luci": [ "setInitAction" ] + }, + "uci": [ "uhttpd" ] + } + }, + + "luci-mod-system-init": { "description": "Grant access to startup configuration", "read": {