Skip to content

Commit 86e901e

Browse files
committed
luci-plugin-pwpolicy: initial commit
Password policy is adds now the possibility to enforce a password policy if it is added to the target. Signed-off-by: Christian Korber <ckorber@tdt.de>
1 parent d890f50 commit 86e901e

3 files changed

Lines changed: 119 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# Copyright (C) 2026 OpenWrt.org
3+
#
4+
# This is free software, licensed under Apache-2.0.
5+
# See /LICENSE for more information.
6+
#
7+
8+
include $(TOPDIR)/rules.mk
9+
10+
PKG_NAME:=luci-plugin-pwpolicy
11+
12+
PKG_LICENSE:=Apache-2.0
13+
PKG_MAINTAINER:=Christian Korber <ckorber@tdt.de>
14+
PKG_DESCRIPTION:=LuCI Password Policy Plugin
15+
16+
LUCI_TITLE:=LuCI Password Policy Plugin
17+
LUCI_DEPENDS:=+luci-base +luci-mod-system
18+
19+
LUCI_TYPE:=plugin
20+
21+
include ../../luci.mk
22+
23+
# call BuildPackage - OpenWrt buildroot
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
'use strict';
2+
'require baseclass';
3+
'require view';
4+
'require form';
5+
6+
return baseclass.extend({
7+
class: 'password',
8+
class_i18n: _('Password'),
9+
10+
type: 'policy',
11+
type_i18n: _('Policy'),
12+
13+
name: 'Password Policy',
14+
id: '51af4ae847774aac863d4c94a9ba6d58',
15+
title: _('Password Policy'),
16+
description: _('Here you can enforce a password policy sytem wide'),
17+
18+
addFormOptions(s) {
19+
let o;
20+
21+
o = s.option(form.Flag, 'enabled', _('Enable password policy'));
22+
o.default = o.disabled;
23+
o.remempty = false;
24+
25+
o = s.option(form.Value, 'pw_length', _('Minimum password length'));
26+
o.optional = false;
27+
o.datatype = 'uinteger';
28+
o.placeholder = 8;
29+
30+
o = s.option(form.Flag, 'digits', _('Digits'));
31+
o.default = false;
32+
33+
o = s.option(form.Flag, 'uc_lc', _('Upper / lower case characters'));
34+
o.default = false;
35+
36+
o = s.option(form.Flag, 'special_characters', _('Special characters'));
37+
o.default = false;
38+
39+
},
40+
41+
configSummary(section) {
42+
if (section.enabled != '1')
43+
return null;
44+
45+
var summary = [];
46+
47+
if (section.pw_length)
48+
summary.push(_('min. password length'));
49+
50+
if (section.digits)
51+
summary.push(_('digit occurence'));
52+
53+
if (section.uc_lc)
54+
summary.push(_('uppercase/lowercase occurence'));
55+
56+
if (section.special_characters)
57+
summary.push(_('special characters occurence'));
58+
59+
return summary.length ? summary.join (', ') : _('Password Policy enabled');
60+
}
61+
});
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
3+
# luci-app-pwpolicy: Setup script for pwpolicy plugin
4+
# This script sets up the password policy plugin configuration in luci_plugins
5+
6+
PLUGIN_UUID="51af4ae847774aac863d4c94a9ba6d58"
7+
8+
# Ensure luci_plugins config file exists
9+
touch /etc/config/luci_plugins
10+
11+
# Create global section if not exists
12+
uci -q get luci_plugins.global >/dev/null || {
13+
uci set luci_plugins.global=global
14+
uci set luci_plugins.global.enabled='0'
15+
}
16+
17+
# Enable pwppolicy plugins class if not set
18+
uci -q get luci_plugins.global.password_policy_enabled >/dev/null || {
19+
uci set luci_plugins.global.password_policy_enabled='0'
20+
}
21+
22+
# Create pwpolicy plugin section if not exists
23+
uci -q get "luci_plugins.${PLUGIN_UUID}" >/dev/null || {
24+
uci set "luci_plugins.${PLUGIN_UUID}=password_policy"
25+
uci set "luci_plugins.${PLUGIN_UUID}.enabled=0"
26+
uci set "luci_plugins.${PLUGIN_UUID}.name=Password Policy"
27+
}
28+
29+
uci set "luci_plugins.${PLUGIN_UUID}.digits=0"
30+
uci set "luci_plugins.${PLUGIN_UUID}.uc_lc=0"
31+
uci set "luci_plugins.${PLUGIN_UUID}.special_characters=0"
32+
33+
uci commit luci_plugins
34+
35+
exit 0

0 commit comments

Comments
 (0)