ipa/freeipa-3.0.0.pre1-013-password-policy-measurement-units.patch
2012-08-06 18:17:49 +02:00

184 lines
7.6 KiB
Diff

From 848bd0e9e738a4590049a223868dcfe6749a9154 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvoborni@redhat.com>
Date: Mon, 9 Jul 2012 16:58:00 +0200
Subject: [PATCH 13/79] Password policy measurement units.
When filling password policy it may be unclear what value to enter because user may not remember field's measurement unit.
This patch adds support for declaring measurement units. It's done in field's/widget's spec by entering key for unit's string (which is in IPA.messages.measurement_units[key]).
Measurement units in table layout are displayed in parenthesis after label. It is to be consistent with some fields which have measurement unit integrated in label.
This patch defines measurement units for password policy's 'History size', 'Failure reset interval' and 'Lockout duration' fields.
https://fedorahosted.org/freeipa/ticket/2437
---
install/ui/field.js | 6 ++++--
install/ui/policy.js | 15 ++++++++++++---
install/ui/test/data/ipa_init.json | 4 ++++
install/ui/user.js | 9 ++++++---
install/ui/widget.js | 15 ++++++++++++++-
ipalib/plugins/internal.py | 4 ++++
6 files changed, 44 insertions(+), 9 deletions(-)
diff --git a/install/ui/field.js b/install/ui/field.js
index 84ec0c4dfa5c77b72da06eb4d2ff64ccac633f65..fb292ff2a6c5fb29b84262236fd5be2c7c7f7e42 100644
--- a/install/ui/field.js
+++ b/install/ui/field.js
@@ -35,6 +35,7 @@ IPA.field = function(spec) {
that.param = spec.param || spec.name;
that.label = spec.label;
that.tooltip = spec.tooltip;
+ that.measurement_unit = spec.measurement_unit;
that.formatter = spec.formatter;
that.widget = null;
@@ -348,8 +349,9 @@ IPA.field = function(spec) {
that.set_widget_flags = function() {
if (that.widget) {
- if(that.label) that.widget.label = that.label;
- if(that.title) that.widget.title = that.title;
+ if (that.label) that.widget.label = that.label;
+ if (that.title) that.widget.title = that.title;
+ if (that.measurement_unit) that.widget.measurement_unit = that.measurement_unit;
that.widget.undo = that.undo;
that.widget.writable = that.writable;
that.widget.read_only = that.read_only;
diff --git a/install/ui/policy.js b/install/ui/policy.js
index 604664f1263e97a7e0007b26b392372fb87b0923..acad0c8c2c2ba6f2f8c26407627b56c75d79dfb5 100644
--- a/install/ui/policy.js
+++ b/install/ui/policy.js
@@ -48,12 +48,21 @@ IPA.pwpolicy.entity = function(spec) {
},
'krbmaxpwdlife',
'krbminpwdlife',
- 'krbpwdhistorylength',
+ {
+ name: 'krbpwdhistorylength',
+ measurement_unit: 'number_of_passwords'
+ },
'krbpwdmindiffchars',
'krbpwdminlength',
'krbpwdmaxfailure',
- 'krbpwdfailurecountinterval',
- 'krbpwdlockoutduration',
+ {
+ name: 'krbpwdfailurecountinterval',
+ measurement_unit: 'seconds'
+ },
+ {
+ name: 'krbpwdlockoutduration',
+ measurement_unit: 'seconds'
+ },
'cospriority'
]
}]}).
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index 85ff9366ce4ad293b95829d864653561a55d6429..527d09163eda854bd779c1362b8272582150e90e 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -138,6 +138,10 @@
"password": "Password",
"username": "Username"
},
+ "measurement_units": {
+ "number_of_passwords": "number of passwords",
+ "seconds": "seconds"
+ },
"objects": {
"aci": {
"attribute": "Attribute"
diff --git a/install/ui/user.js b/install/ui/user.js
index 02f6f73e45e50b8c5501ccad57209a681100082d..24873ecf55d5e9159d77dc061d73f3d2e318e30d 100644
--- a/install/ui/user.js
+++ b/install/ui/user.js
@@ -149,7 +149,8 @@ IPA.user.entity = function(spec) {
{
name: 'krbpwdhistorylength',
label: IPA.get_entity_param('pwpolicy', 'krbpwdhistorylength').label,
- read_only: true
+ read_only: true,
+ measurement_unit: 'number_of_passwords'
},
{
name: 'krbpwdmindiffchars',
@@ -169,12 +170,14 @@ IPA.user.entity = function(spec) {
{
name: 'krbpwdfailurecountinterval',
label: IPA.get_entity_param('pwpolicy', 'krbpwdfailurecountinterval').label,
- read_only: true
+ read_only: true,
+ measurement_unit: 'seconds'
},
{
name: 'krbpwdlockoutduration',
label: IPA.get_entity_param('pwpolicy', 'krbpwdlockoutduration').label,
- read_only: true
+ read_only: true,
+ measurement_unit: 'seconds'
}
]
},
diff --git a/install/ui/widget.js b/install/ui/widget.js
index a55cc347f49cc2e61f00422f12c47ab4c1c70449..64547da7d439cb622c03d6f73afb310be83a6338 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -36,6 +36,7 @@ IPA.widget = function(spec) {
that.id = spec.id;
that.label = spec.label;
that.tooltip = spec.tooltip;
+ that.measurement_unit = spec.measurement_unit;
that.entity = IPA.get_entity(spec.entity); //some old widgets still need it
that.facet = spec.facet;
@@ -2688,10 +2689,12 @@ IPA.table_layout = function(spec) {
title: widget.label
}).appendTo(tr);
+ var label_text = widget.label + that.get_measurement_unit_text(widget) + ':';
+
$('<label/>', {
name: widget.name,
'class': that.label_class,
- text: widget.label+':'
+ text: label_text
}).appendTo(td);
if(widget.create_required) {
@@ -2713,6 +2716,16 @@ IPA.table_layout = function(spec) {
return table;
};
+
+ that.get_measurement_unit_text = function(widget) {
+
+ if (widget.measurement_unit) {
+ var unit = IPA.messages.measurement_units[widget.measurement_unit];
+ return ' (' + unit + ')';
+ }
+ return '';
+ };
+
return that;
};
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index a4d87b1d744afe38b5e4ca1b6789724b33d6aa57..eb48b3bfa44ca681920daaf4c0f8a8ccfa86f3fa 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -273,6 +273,10 @@ class i18n_messages(Command):
"password": _("Password"),
"username": _("Username"),
},
+ "measurement_units": {
+ "number_of_passwords": _("number of passwords"),
+ "seconds": _("seconds"),
+ },
"objects": {
"aci": {
"attribute": _("Attribute"),
--
1.7.11.2