From afededacb92ce1903885b265c7adca87b634c21a Mon Sep 17 00:00:00 2001
From: Pavel Vomacka
Date: Mon, 6 Jun 2016 12:11:06 +0200
Subject: [PATCH] Auth Indicators WebUI part
Add custom_checkbox_widget on service page. The old aci.attribute_widget
now inherits from the new base class custom_checkboxes_widget and overrides
the populate method.
https://fedorahosted.org/freeipa/ticket/5872
Reviewed-By: Petr Vobornik
---
install/ui/src/freeipa/aci.js | 173 ++------------------------
install/ui/src/freeipa/service.js | 20 +++
install/ui/src/freeipa/widget.js | 187 +++++++++++++++++++++++++++++
install/ui/test/data/ipa_init.json | 11 +-
ipaserver/plugins/internal.py | 11 +-
5 files changed, 233 insertions(+), 169 deletions(-)
diff --git a/install/ui/src/freeipa/aci.js b/install/ui/src/freeipa/aci.js
index 9a19dd7b4..6ac7f4c71 100644
--- a/install/ui/src/freeipa/aci.js
+++ b/install/ui/src/freeipa/aci.js
@@ -537,146 +537,24 @@ return {
}
};};
-/**
- * @class aci.attributes_widget
- * @extends IPA.checkboxes_widget
- */
aci.attributes_widget = function(spec) {
spec = spec || {};
spec.layout = spec.layout || 'columns attribute_widget';
- spec.sort = spec.sort === undefined ? true : spec.sort;
+ spec.add_dialog_title = spec.add_dialog_title ||
+ "@i18n:objects.permission.add_custom_attr";
+ spec.add_field_label = spec.add_field_label ||
+ '@i18n:objects.permission.attribute';
- var that = IPA.checkboxes_widget(spec);
-
- /**
- * Additional options which are not defined in metadata
- * @property {string[]}
- */
- that.custom_options = spec.custom_options || [];
+ var that = IPA.custom_checkboxes_widget(spec);
that.object_type = spec.object_type;
- that.skip_unmatched = spec.skip_unmatched === undefined ? false : spec.skip_unmatched;
- var id = spec.name;
+ that.populate = function() {
- that.create = function(container) {
- that.container = container;
- that.widget_create(container);
+ if (!that.object_type || that.object_type === '') return;
- that.controls = $('
', {
- 'class': 'form-inline controls'
- });
- that.controls.appendTo(container);
- that.create_search_filter(that.controls);
- that.create_add_control(that.controls);
- if (that.undo) {
- that.create_undo(that.controls);
- }
-
- that.owb_create(container);
-
- that.create_error_link(container);
- };
-
- that.create_search_filter = function(container) {
- var filter_container = $('
', {
- 'class': 'search-filter'
- });
-
- that.filter = $(' ', {
- type: 'text',
- name: 'filter',
- 'class': 'form-control',
- placeholder: text.get('@i18n:objects.permission.filter')
- }).appendTo(filter_container);
-
- that.filter.keyup(function(e) {
- that.filter_options();
- });
-
- var find_button = IPA.action_button({
- name: 'find',
- icon: 'fa-search',
- click: function() {
- that.filter_options();
- return false;
- }
- }).appendTo(filter_container);
-
- filter_container.appendTo(container);
- };
-
- that.create_add_control = function(container) {
-
- that.add_button = IPA.button({
- label: '@i18n:buttons.add',
- click: that.show_add_dialog
- });
- container.append(' ');
- that.add_button.appendTo(container);
- };
-
- that.show_add_dialog = function() {
-
- var dialog = IPA.form_dialog({
- name: "add_option",
- title: "@i18n:objects.permission.add_custom_attr",
- fields: [
- {
- name: 'attr',
- label: '@i18n:objects.permission.attribute',
- required: true
- }
- ]
- });
- dialog.on_confirm = function() {
- if (!dialog.validate()) return;
- var attr = dialog.get_field('attr');
- var value = attr.get_value()[0];
- that.add_custom_option(value, false, true, true);
- dialog.close();
- };
- dialog.open();
- };
-
- that.filter_options = function() {
- $("li", that.$node).each(function() {
- var item = $(this);
- if(item.find('input').val().indexOf(that.filter.val()) === -1) {
- item.css('display','none');
- } else {
- item.css('display','inline');
- }
- });
- };
-
- that.update = function(values) {
-
- that.values = [];
-
- values = values || [];
- for (var i=0; i', {
+ 'class': 'form-inline controls'
+ });
+ that.controls.appendTo(container);
+ that.create_search_filter(that.controls);
+ that.create_add_control(that.controls);
+ if (that.undo) {
+ that.create_undo(that.controls);
+ }
+
+ that.owb_create(container);
+
+ that.create_error_link(container);
+ };
+
+ that.create_search_filter = function(container) {
+ var filter_container = $('
', {
+ 'class': 'search-filter'
+ });
+
+ that.filter = $(' ', {
+ type: 'text',
+ name: 'filter',
+ 'class': 'form-control',
+ placeholder: text.get('@i18n:search.placeholder_filter')
+ }).appendTo(filter_container);
+
+ that.filter.keyup(function(e) {
+ that.filter_options();
+ });
+
+ var find_button = IPA.action_button({
+ name: 'find',
+ icon: 'fa-search',
+ click: function() {
+ that.filter_options();
+ return false;
+ }
+ }).appendTo(filter_container);
+
+ filter_container.appendTo(container);
+ };
+
+ that.create_add_control = function(container) {
+
+ that.add_button = IPA.button({
+ label: '@i18n:buttons.add',
+ click: that.show_add_dialog
+ });
+ container.append(' ');
+ that.add_button.appendTo(container);
+ };
+
+ that.show_add_dialog = function() {
+
+ var dialog = IPA.form_dialog({
+ name: "add_option",
+ title: that.add_dialog_title,
+ fields: [
+ {
+ name: 'custom_value',
+ label: that.add_field_label,
+ required: true
+ }
+ ]
+ });
+ dialog.on_confirm = function() {
+ if (!dialog.validate()) return;
+ var attr = dialog.get_field('custom_value');
+ var value = attr.get_value()[0];
+ that.add_custom_option(value, false, true, true);
+ dialog.close();
+ };
+ dialog.open();
+ };
+
+ that.filter_options = function() {
+ $("li", that.$node).each(function() {
+ var item = $(this);
+ if(item.find('input').val().indexOf(that.filter.val()) === -1) {
+ item.css('display','none');
+ } else {
+ item.css('display','inline');
+ }
+ });
+ };
+
+ that.update = function(values) {
+
+ that.values = [];
+
+ values = values || [];
+ for (var i=0; iImplicit method (password) will be used if no method is chosen.
Password + Two-factor: LDAP and Kerberos allow authentication with either one of the authentication types but Kerberos uses pre-authentication method which requires to use armor ccache.
RADIUS with another type: Kerberos always use RADIUS, but LDAP never does. LDAP only recognize the password and two-factor authentication options.
",
+ "otp": "OTP",
"type_otp": "Two factor authentication (password + OTP)",
"type_password": "Password",
- "type_radius": "Radius",
+ "type_radius": "RADIUS",
"type_disabled": "Disable per-user override",
"user_tooltip": "Per-user setting, overwrites the global setting if any option is checked.
Password + Two-factor: LDAP and Kerberos allow authentication with either one of the authentication types but Kerberos uses pre-authentication method which requires to use armor ccache.
RADIUS with another type: Kerberos always use RADIUS, but LDAP never does. LDAP only recognize the password and two-factor authentication options.
",
},
@@ -106,11 +107,13 @@
},
"dialogs": {
"add_confirmation": "${entity} successfully added",
+ "add_custom_value": "Add custom value",
"add_title": "Add ${entity}",
"available": "Available",
"batch_error_message": "Some operations failed.",
"batch_error_title": "Operations Error",
"confirmation": "Confirmation",
+ "custom_value": "Custom value",
"dirty_message": "This page has unsaved changes. Please save or revert.",
"dirty_title": "Unsaved Changes",
"edit_title": "Edit ${entity}",
@@ -469,7 +472,7 @@
"type_totp": "Time-based (TOTP)"
},
"permission": {
- "add_custom_attr": "Add custom attribute",
+ "add_custom_attr": "Add Custom Attribute",
"attribute": "Attribute",
"filter": "Filter",
"identity": "Permission settings",
@@ -519,7 +522,10 @@
"user": "User"
},
"service": {
+ "auth_indicators": "Authentication indicators",
+ "auth_indicator": "Authentication indicator",
"certificate": "Service Certificate",
+ "custom_auth_ind_title": "Add Custom Authentication Indicator",
"delete_key_unprovision": "Delete Key, Unprovision",
"details": "Service Settings",
"host": "Host Name",
@@ -660,6 +666,7 @@
"enabled": "${count} item(s) enabled",
"partial_delete": "Some entries were not deleted",
"placeholder": "Search",
+ "placeholder_filter": "Filter",
"quick_links": "Quick Links",
"select_all": "Select All",
"truncated": "Query returned more results than the configured size limit. Displaying the first ${counter} results.",
diff --git a/ipaserver/plugins/internal.py b/ipaserver/plugins/internal.py
index 053c47174..4804f64a0 100644
--- a/ipaserver/plugins/internal.py
+++ b/ipaserver/plugins/internal.py
@@ -185,9 +185,10 @@ class i18n_messages(Command):
},
"authtype": {
"config_tooltip": _("Implicit method (password) will be used if no method is chosen.
Password + Two-factor: LDAP and Kerberos allow authentication with either one of the authentication types but Kerberos uses pre-authentication method which requires to use armor ccache.
RADIUS with another type: Kerberos always use RADIUS, but LDAP never does. LDAP only recognize the password and two-factor authentication options.
"),
+ "otp": _("OTP"),
"type_otp": _("Two factor authentication (password + OTP)"),
"type_password": _("Password"),
- "type_radius": _("Radius"),
+ "type_radius": _("RADIUS"),
"type_disabled": _("Disable per-user override"),
"user_tooltip": _("Per-user setting, overwrites the global setting if any option is checked.
Password + Two-factor: LDAP and Kerberos allow authentication with either one of the authentication types but Kerberos uses pre-authentication method which requires to use armor ccache.
RADIUS with another type: Kerberos always use RADIUS, but LDAP never does. LDAP only recognize the password and two-factor authentication options.
"),
},
@@ -242,11 +243,13 @@ class i18n_messages(Command):
},
"dialogs": {
"add_confirmation": _("${entity} successfully added"),
+ "add_custom_value": _("Add custom value"),
"add_title": _("Add ${entity}"),
"available": _("Available"),
"batch_error_message": _("Some operations failed."),
"batch_error_title": _("Operations Error"),
"confirmation": _("Confirmation"),
+ "custom_value": _("Custom value"),
"dirty_message": _("This page has unsaved changes. Please save or revert."),
"dirty_title": _("Unsaved Changes"),
"edit_title": _("Edit ${entity}"),
@@ -607,7 +610,7 @@ class i18n_messages(Command):
"type_totp": _("Time-based (TOTP)"),
},
"permission": {
- "add_custom_attr": _("Add custom attribute"),
+ "add_custom_attr": _("Add Custom Attribute"),
"attribute": _("Attribute"),
"filter": _("Filter"),
"identity": _("Permission settings"),
@@ -658,7 +661,10 @@ class i18n_messages(Command):
"user": _("User"),
},
"service": {
+ "auth_indicators": _("Authentication indicators"),
+ "auth_indicator": _("Authentication indicator"),
"certificate": _("Service Certificate"),
+ "custom_auth_ind_title": _("Add Custom Authentication Indicator"),
"delete_key_unprovision": _("Delete Key, Unprovision"),
"details": _("Service Settings"),
"host": _("Host Name"),
@@ -799,6 +805,7 @@ class i18n_messages(Command):
"enabled": _("${count} item(s) enabled"),
"partial_delete": _("Some entries were not deleted"),
"placeholder": _("Search"),
+ "placeholder_filter": _("Filter"),
"quick_links": _("Quick Links"),
"select_all": _("Select All"),
"truncated": _("Query returned more results than the configured size limit. Displaying the first ${counter} results."),