luci-mod-system: allow configuration of HTTPS redirection
authorPetr Štetiar <[email protected]>
Mon, 14 Dec 2020 12:11:08 +0000 (13:11 +0100)
committerPaul Spooren <[email protected]>
Tue, 28 Sep 2021 20:46:36 +0000 (10:46 -1000)
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 <[email protected]>
modules/luci-mod-system/htdocs/luci-static/resources/view/system/uhttpd.js [new file with mode: 0644]
modules/luci-mod-system/root/usr/share/luci/menu.d/luci-mod-system.json
modules/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json

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 (file)
index 0000000..d02e185
--- /dev/null
@@ -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 <abbr title="Hypertext Transfer Protocol">HTTP</abbr> or <abbr title="Hypertext Transfer Protocol Secure">HTTPS</abbr> 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 <abbr title="Hypertext Transfer Protocol">HTTP</abbr> requests to <abbr title="Hypertext Transfer Protocol Secure">HTTPS</abbr> port.'));
+               o.enabled  = 'on';
+               o.disabled = 'off';
+               o.default  = o.disabled;
+               o.rmempty = false;
+
+               return m.render();
+       }
+});
index 4022e0cebf03fa29b598d581acb3c97353996d72..ebae989d0e00b5771453565fb6d10243ccbe9943 100644 (file)
                }
        },
 
+       "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,
index e04bcdb476a7360904118e05f49eaf12ad57ba4b..9acb6e4471b0ebb071d22b6546a8bf8cacaa56b1 100644 (file)
                }
        },
 
+       "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": {