f56551
From be48983558a560dadad410a70a4a1684565ed481 Mon Sep 17 00:00:00 2001
f56551
From: Alexander Scheel <ascheel@redhat.com>
f56551
Date: Mon, 15 Jun 2020 18:38:35 -0400
f56551
Subject: [PATCH] Clarify AJP connector creation process
f56551
f56551
We do two things:
f56551
f56551
 1. Fix the xpath for AJP connector verification. An AJP connector is
f56551
    one which has protocol="AJP/1.3", NOT one that has port="8009". An
f56551
    AJP connector can exist on any port and port 8009 can have any
f56551
    protocol. Secrets only make sense on AJP connectors, so make the
f56551
    xpath match the existing comment.
f56551
f56551
 2. Add some background in-line documentation about AJP secret
f56551
    provisioning. This should help future developers understand why this
f56551
    was added to IPA and what limitations there are in what PKI or IPA
f56551
    can do. Most notably, explain why Dogtag can't upgrade the AJP
f56551
    connector to have a secret in the general case.
f56551
f56551
Signed-off-by: Alexander Scheel <ascheel@redhat.com>
f56551
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
f56551
---
f56551
 ipaserver/install/dogtaginstance.py | 20 +++++++++++++++++---
f56551
 1 file changed, 17 insertions(+), 3 deletions(-)
f56551
f56551
diff --git a/ipaserver/install/dogtaginstance.py b/ipaserver/install/dogtaginstance.py
f56551
index 42c9db3fb..aa3baeb7c 100644
f56551
--- a/ipaserver/install/dogtaginstance.py
f56551
+++ b/ipaserver/install/dogtaginstance.py
f56551
@@ -308,11 +308,12 @@ class DogtagInstance(service.Service):
f56551
         doc = server_xml.getroot()
f56551
 
f56551
         # no AJP connector means no need to update anything
f56551
-        connectors = doc.xpath('//Connector[@port="8009"]')
f56551
+        connectors = doc.xpath('//Connector[@protocol="AJP/1.3"]')
f56551
         if len(connectors) == 0:
f56551
             return
f56551
 
f56551
-        # AJP connector is set on port 8009. Use non-greedy search to find it
f56551
+        # AJP protocol is at version 1.3. Assume there is only one as
f56551
+        # Dogtag only provisions one.
f56551
         connector = connectors[0]
f56551
 
f56551
         # Detect tomcat version and choose the right option name
f56551
@@ -331,11 +332,24 @@ class DogtagInstance(service.Service):
f56551
             rewrite = False
f56551
         else:
f56551
             if oldattr in connector.attrib:
f56551
+                # Sufficiently new Dogtag versions (10.9.0-a2) handle the
f56551
+                # upgrade for us; we need only to ensure that we're not both
f56551
+                # attempting to upgrade server.xml at the same time.
f56551
+                # Hopefully this is guaranteed for us.
f56551
                 self.ajp_secret = connector.attrib[oldattr]
f56551
                 connector.attrib[secretattr] = self.ajp_secret
f56551
                 del connector.attrib[oldattr]
f56551
             else:
f56551
-                # Generate password, don't use special chars to not break XML
f56551
+                # Generate password, don't use special chars to not break XML.
f56551
+                #
f56551
+                # If we hit this case, pkispawn was run on an older Dogtag
f56551
+                # version and we're stuck migrating, choosing a password
f56551
+                # ourselves. Dogtag can't generate one randomly because a
f56551
+                # Dogtag administrator might've configured AJP and might
f56551
+                # not be using IPA.
f56551
+                #
f56551
+                # Newer Dogtag versions will generate a random password
f56551
+                # during pkispawn.
f56551
                 self.ajp_secret = ipautil.ipa_generate_password(special=None)
f56551
                 connector.attrib[secretattr] = self.ajp_secret
f56551
 
f56551
-- 
f56551
2.26.2
f56551
f56551
From 1e804bf19da4ee274e735fd49452d4df5d73a002 Mon Sep 17 00:00:00 2001
f56551
From: Alexander Scheel <ascheel@redhat.com>
f56551
Date: Wed, 17 Jun 2020 16:00:25 -0400
f56551
Subject: [PATCH] Configure PKI AJP Secret with 256-bit secret
f56551
f56551
By default, PKI's AJP secret is generated as a 75-bit password. By
f56551
generating it in IPA, we can guarantee the strength of the AJP secret.
f56551
It makes sense to use a stronger AJP secret because it typically
f56551
isn't rotated; access to AJP allows an attacker to impersonate an admin
f56551
while talking to PKI.
f56551
f56551
Fixes: https://pagure.io/freeipa/issue/8372
f56551
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1849146
f56551
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1845447
f56551
Related: https://github.com/dogtagpki/pki/pull/437
f56551
f56551
Signed-off-by: Alexander Scheel <ascheel@redhat.com>
f56551
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
f56551
---
f56551
 install/share/ipaca_customize.ini   | 1 +
f56551
 install/share/ipaca_default.ini     | 2 ++
f56551
 ipaserver/install/dogtaginstance.py | 4 +++-
f56551
 3 files changed, 6 insertions(+), 1 deletion(-)
f56551
f56551
diff --git a/install/share/ipaca_customize.ini b/install/share/ipaca_customize.ini
f56551
index 6d58579af..948734241 100644
f56551
--- a/install/share/ipaca_customize.ini
f56551
+++ b/install/share/ipaca_customize.ini
f56551
@@ -12,6 +12,7 @@
f56551
 #
f56551
 # Predefined variables
f56551
 #  - ipa_ca_subject
f56551
+#  - ipa_ajp_secret
f56551
 #  - ipa_fqdn
f56551
 #  - ipa_subject_base
f56551
 #  - pki_admin_password
f56551
diff --git a/install/share/ipaca_default.ini b/install/share/ipaca_default.ini
f56551
index 2b9900286..a51256116 100644
f56551
--- a/install/share/ipaca_default.ini
f56551
+++ b/install/share/ipaca_default.ini
f56551
@@ -12,6 +12,7 @@ ipa_ca_pem_file=/etc/ipa/ca.crt
f56551
 
f56551
 ## dynamic values
f56551
 # ipa_ca_subject=
f56551
+# ipa_ajp_secret=
f56551
 # ipa_subject_base=
f56551
 # ipa_fqdn=
f56551
 # ipa_ocsp_uri=
f56551
@@ -66,6 +67,7 @@ pki_issuing_ca=%(pki_issuing_ca_uri)s
f56551
 pki_replication_password=
f56551
 
f56551
 pki_enable_proxy=True
f56551
+pki_ajp_secret=%(ipa_ajp_secret)s
f56551
 pki_restart_configured_instance=False
f56551
 pki_security_domain_hostname=%(ipa_fqdn)s
f56551
 pki_security_domain_https_port=443
f56551
diff --git a/ipaserver/install/dogtaginstance.py b/ipaserver/install/dogtaginstance.py
f56551
index aa3baeb7c..361d80a8c 100644
f56551
--- a/ipaserver/install/dogtaginstance.py
f56551
+++ b/ipaserver/install/dogtaginstance.py
f56551
@@ -840,7 +840,9 @@ class PKIIniLoader:
f56551
             pki_subsystem_type=subsystem.lower(),
f56551
             home_dir=os.path.expanduser("~"),
f56551
             # for softhsm2 testing
f56551
-            softhsm2_so=paths.LIBSOFTHSM2_SO
f56551
+            softhsm2_so=paths.LIBSOFTHSM2_SO,
f56551
+            # Configure a more secure AJP password by default
f56551
+            ipa_ajp_secret=ipautil.ipa_generate_password(special=None)
f56551
         )
f56551
 
f56551
     @classmethod
f56551
-- 
f56551
2.26.2
f56551