pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0026-WebUI-Allow-to-add-certs-to-certmapping-with-CERT-LI.patch

483b06
From be6eedde5a5aaf7ad1b527c0cfb9699ccb98a6b5 Mon Sep 17 00:00:00 2001
483b06
From: Pavel Vomacka <pvomacka@redhat.com>
483b06
Date: Mon, 27 Mar 2017 14:14:32 +0200
483b06
Subject: [PATCH] WebUI: Allow to add certs to certmapping with CERT LINES
483b06
 around
483b06
483b06
The certificate to the certmapping might be inserted as
483b06
base64 encoded blob. This patch allows to also insert the certificate
483b06
blob with surrounding "-----BEGIN CERTIFICATE-----" and
483b06
"-----END CERTIFICATE-----" lines. This behavior is the same in
483b06
widget for assigning certificates to users, so the change helps
483b06
WebUI to be more consistent.
483b06
483b06
https://pagure.io/freeipa/issue/6772
483b06
483b06
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
483b06
Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
483b06
---
483b06
 install/ui/src/freeipa/plugins/certmap.js | 13 +++++++++++--
483b06
 1 file changed, 11 insertions(+), 2 deletions(-)
483b06
483b06
diff --git a/install/ui/src/freeipa/plugins/certmap.js b/install/ui/src/freeipa/plugins/certmap.js
483b06
index ecbe095b9ead5c3dad70380202836608d564cd58..c613601e989f065a3d6289b02b60563020acf978 100644
483b06
--- a/install/ui/src/freeipa/plugins/certmap.js
483b06
+++ b/install/ui/src/freeipa/plugins/certmap.js
483b06
@@ -8,6 +8,7 @@ define([
483b06
         'dojo/_base/declare',
483b06
         'dojo/Evented',
483b06
         'dojo/on',
483b06
+        '../certificate',
483b06
         '../navigation',
483b06
         '../field',
483b06
         '../ipa',
483b06
@@ -19,8 +20,8 @@ define([
483b06
         // plain imports
483b06
         '../search',
483b06
         '../entity'],
483b06
-            function(lang, declare, Evented, on, navigation, mod_field, IPA,
483b06
-                     phases, reg, widget_mod, text, util) {
483b06
+            function(lang, declare, Evented, on, certificate, navigation,
483b06
+                 mod_field, IPA, phases, reg, widget_mod, text, util) {
483b06
 /**
483b06
  * Certificate map module
483b06
  * @class
483b06
@@ -312,6 +313,12 @@ certmap.certmap_multivalued_widget = function (spec) {
483b06
         var widget = widgets[0];
483b06
         var inner_widgets = widget.widgets.get_widgets();
483b06
 
483b06
+        var normalize_certs = function(certs) {
483b06
+            for (var k = 0, l = certs.length; k
483b06
+                certs[k] = certificate.get_base64(certs[k]);
483b06
+            }
483b06
+        };
483b06
+
483b06
         for (var i = 0, l = inner_widgets.length; i
483b06
             var w = inner_widgets[i];
483b06
 
483b06
@@ -321,6 +328,8 @@ certmap.certmap_multivalued_widget = function (spec) {
483b06
 
483b06
                 if (field.name === 'issuer' || field.name === 'subject') {
483b06
                     value = value[0];
483b06
+                } else if (field.name === 'certificate') {
483b06
+                    normalize_certs(value);
483b06
                 }
483b06
 
483b06
                 if (!util.is_empty(value)) options[field.name] = value;
483b06
-- 
483b06
2.12.1
483b06