URL: https://github.com/freeipa/freeipa/pull/659
Author: pvomacka
 Title: #659: WebUI: Allow to add certs to certmapping with CERT LINES around
Action: opened

PR body:
"""
The certificate to the certmapping might be inserted as
base64 encoded blob. This patch allows to also insert the certificate
blob with surrounding "-----BEGIN CERTIFICATE-----" and
"-----END CERTIFICATE-----" lines. This behavior is the same in
widget for assigning certificates to users, so the change helps
WebUI to be more consistent.

https://pagure.io/freeipa/issue/6772
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/659/head:pr659
git checkout pr659
From ad8d00741589c2a6d9e036f7c8451579f2eec9b1 Mon Sep 17 00:00:00 2001
From: Pavel Vomacka <pvoma...@redhat.com>
Date: Mon, 27 Mar 2017 14:14:32 +0200
Subject: [PATCH] WebUI: Allow to add certs to certmapping with CERT LINES
 around

The certificate to the certmapping might be inserted as
base64 encoded blob. This patch allows to also insert the certificate
blob with surrounding "-----BEGIN CERTIFICATE-----" and
"-----END CERTIFICATE-----" lines. This behavior is the same in
widget for assigning certificates to users, so the change helps
WebUI to be more consistent.

https://pagure.io/freeipa/issue/6772
---
 install/ui/src/freeipa/plugins/certmap.js | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/install/ui/src/freeipa/plugins/certmap.js b/install/ui/src/freeipa/plugins/certmap.js
index ecbe095..c613601 100644
--- a/install/ui/src/freeipa/plugins/certmap.js
+++ b/install/ui/src/freeipa/plugins/certmap.js
@@ -8,6 +8,7 @@ define([
         'dojo/_base/declare',
         'dojo/Evented',
         'dojo/on',
+        '../certificate',
         '../navigation',
         '../field',
         '../ipa',
@@ -19,8 +20,8 @@ define([
         // plain imports
         '../search',
         '../entity'],
-            function(lang, declare, Evented, on, navigation, mod_field, IPA,
-                     phases, reg, widget_mod, text, util) {
+            function(lang, declare, Evented, on, certificate, navigation,
+                 mod_field, IPA, phases, reg, widget_mod, text, util) {
 /**
  * Certificate map module
  * @class
@@ -312,6 +313,12 @@ certmap.certmap_multivalued_widget = function (spec) {
         var widget = widgets[0];
         var inner_widgets = widget.widgets.get_widgets();
 
+        var normalize_certs = function(certs) {
+            for (var k = 0, l = certs.length; k<l; k++) {
+                certs[k] = certificate.get_base64(certs[k]);
+            }
+        };
+
         for (var i = 0, l = inner_widgets.length; i<l; i++) {
             var w = inner_widgets[i];
 
@@ -321,6 +328,8 @@ certmap.certmap_multivalued_widget = function (spec) {
 
                 if (field.name === 'issuer' || field.name === 'subject') {
                     value = value[0];
+                } else if (field.name === 'certificate') {
+                    normalize_certs(value);
                 }
 
                 if (!util.is_empty(value)) options[field.name] = value;
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to