From: Christian Korber Date: Fri, 15 May 2026 08:44:31 +0000 (+0200) Subject: luci-mod-system: add password policy X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=5aa08be2cbf890fff6b5d1cbad487d424e928883;p=openwrt-luci.git luci-mod-system: add password policy Initial commit to add password policy options to `luci-mod-system`. Signed-off-by: Christian Korber --- 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 index 0000000000..4dc8841cd8 --- /dev/null +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/pwpolicy.js @@ -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
(e.g., !, @, #, $, %, &)')); + o.default = o.disabled; + o.rmempty = true; + o.depends('enabled', '1'); + + 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 488a36b835..372c618be4 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 @@ -34,9 +34,21 @@ } }, + "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" 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 55de850325..98b47d7afb 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 @@ -222,5 +222,16 @@ "system": [ "reboot" ] } } + }, + + "luci-mod-system-pwpolicy": { + "description": "Grant access to password policy configuration", + "read": { + "uci": [ "rpcd" ] + }, + "write": { + "uci": [ "rpcd" ] + } } + }