luci-mod-system: add password policy
authorChristian Korber <redacted>
Fri, 15 May 2026 08:44:31 +0000 (10:44 +0200)
committerPaul Donald <redacted>
Wed, 3 Jun 2026 10:49:07 +0000 (13:49 +0300)
Initial commit to add password policy options to `luci-mod-system`.

Signed-off-by: Christian Korber <redacted>
modules/luci-mod-system/htdocs/luci-static/resources/view/system/pwpolicy.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/pwpolicy.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/pwpolicy.js
new file mode 100644 (file)
index 0000000..4dc8841
--- /dev/null
@@ -0,0 +1,57 @@
+'use strict';
+
+'require form';
+'require uci';
+'require view';
+
+return view.extend({
+       load: function () {
+               return Promise.all([
+                       uci.load('rpcd')
+               ]);
+       },
+
+       render: function () {
+               let m, s, o;
+
+               if (!uci.get('rpcd', 'policy'))
+                       uci.add('rpcd', 'policy', 'policy');
+
+               m = new form.Map('rpcd', _('Policy'));
+               m.readonly = !L.hasViewPermission();
+
+               s = m.section(form.NamedSection, 'policy')
+               s.addremove = false;
+               s.anonymous = true;
+
+               o = s.option(form.Flag, 'enabled',
+                       _('Enable password policy'));
+               o.default = o.disabled;
+
+               o = s.option(form.Value, 'pw_length',
+                       _('Require a minimum password length'));
+               o.datatype = 'uinteger';
+               o.rmempty = true;
+               o.depends('enabled', '1');
+
+               o = s.option(form.Flag, 'digits',
+                       _('Require digits'));
+               o.default = o.disabled;
+               o.rmempty = true;
+               o.depends('enabled', '1');
+
+               o = s.option(form.Flag, 'uc_lc',
+                       _('Require upper/lower case'));
+               o.default = o.disabled;
+               o.rmempty = true;
+               o.depends('enabled', '1');
+
+               o = s.option(form.Flag, 'special_characters',
+                       _('Require special characters <br/> (e.g., !, @, #, $, %, &)'));
+               o.default = o.disabled;
+               o.rmempty = true;
+               o.depends('enabled', '1');
+
+               return m.render();
+       }
+});
index 488a36b83555f4bc63fbf57df57a02dc6bdad744..372c618be457ff7dd1f2865cafaf79756d57992b 100644 (file)
                }
        },
 
+       "admin/system/admin/pwpolicy": {
+               "title": "Password Policy",
+               "order": 2,
+               "action": {
+                       "type": "view",
+                       "path": "system/pwpolicy"
+               },
+               "depends": {
+                       "acl": [ "luci-mod-system-pwpolicy" ]
+               }
+       },
+
        "admin/system/admin/dropbear": {
                "title": "SSH Access",
-               "order": 2,
+               "order": 5,
                "action": {
                        "type": "view",
                        "path": "system/dropbear"
@@ -49,7 +61,7 @@
 
        "admin/system/admin/sshkeys": {
                "title": "SSH-Keys",
-               "order": 3,
+               "order": 6,
                "action": {
                        "type": "view",
                        "path": "system/sshkeys"
@@ -62,7 +74,7 @@
 
        "admin/system/admin/uhttpd": {
                "title": "HTTP(S) Access",
-               "order": 4,
+               "order": 7,
                "action": {
                        "type": "view",
                        "path": "system/uhttpd"
@@ -75,7 +87,7 @@
 
        "admin/system/admin/repokeys": {
                "title": "Repo Public Keys",
-               "order": 5,
+               "order": 8,
                "action": {
                        "type": "view",
                        "path": "system/repokeys"
@@ -87,7 +99,7 @@
 
        "admin/system/plugins": {
                "title": "Plugins",
-               "order": 3,
+               "order": 4,
                "action": {
                        "type": "view",
                        "path": "system/plugins"
index 55de8503256b9679f0b1ac2ee8c0fbb42a81af2b..98b47d7afbbd71f239d9a4964b0a139d1d608eca 100644 (file)
                                "system": [ "reboot" ]
                        }
                }
+       },
+
+       "luci-mod-system-pwpolicy": {
+               "description": "Grant access to password policy configuration",
+               "read": {
+                       "uci": [ "rpcd" ]
+               },
+               "write": {
+                       "uci": [ "rpcd" ]
+               }
        }
+
 }
git clone https://git.99rst.org/PROJECT