|
|
7e1b55 |
From 538a9992fd1394ed24cbcdf2a2a27694ac28da55 Mon Sep 17 00:00:00 2001
|
|
|
7e1b55 |
From: Antonio Torres <antorres@redhat.com>
|
|
|
7e1b55 |
Date: Mon, 8 Mar 2021 18:20:35 +0100
|
|
|
7e1b55 |
Subject: [PATCH] ipatests: ensure auth indicators can't be added to internal
|
|
|
7e1b55 |
IPA services
|
|
|
7e1b55 |
|
|
|
7e1b55 |
Authentication indicators should not be added to internal IPA services,
|
|
|
7e1b55 |
since this can lead to a broken IPA setup. In case a client with
|
|
|
7e1b55 |
an auth indicator set in its host principal, promoting it to a replica
|
|
|
7e1b55 |
should fail.
|
|
|
7e1b55 |
|
|
|
7e1b55 |
Related: https://pagure.io/freeipa/issue/8206
|
|
|
7e1b55 |
Signed-off-by: Antonio Torres <antorres@redhat.com>
|
|
|
7e1b55 |
---
|
|
|
7e1b55 |
.../test_replica_promotion.py | 38 +++++++++++++++++++
|
|
|
7e1b55 |
ipatests/test_xmlrpc/test_host_plugin.py | 10 +++++
|
|
|
7e1b55 |
ipatests/test_xmlrpc/test_service_plugin.py | 21 ++++++++++
|
|
|
7e1b55 |
3 files changed, 69 insertions(+)
|
|
|
7e1b55 |
|
|
|
7e1b55 |
diff --git a/ipatests/test_integration/test_replica_promotion.py b/ipatests/test_integration/test_replica_promotion.py
|
|
|
7e1b55 |
index 0a137dbdcb068811899e7ff7914730f14ea651c1..b9c56f775d08885cb6b1226eeb7bcf105f87cdc1 100644
|
|
|
7e1b55 |
--- a/ipatests/test_integration/test_replica_promotion.py
|
|
|
7e1b55 |
+++ b/ipatests/test_integration/test_replica_promotion.py
|
|
|
7e1b55 |
@@ -101,6 +101,44 @@ class TestReplicaPromotionLevel1(ReplicaPromotionBase):
|
|
|
7e1b55 |
assert result.returncode == 1
|
|
|
7e1b55 |
assert expected_err in result.stderr_text
|
|
|
7e1b55 |
|
|
|
7e1b55 |
+ @replicas_cleanup
|
|
|
7e1b55 |
+ def test_install_with_host_auth_ind_set(self):
|
|
|
7e1b55 |
+ """ A client shouldn't be able to be promoted if it has
|
|
|
7e1b55 |
+ any auth indicator set in the host principal.
|
|
|
7e1b55 |
+ https://pagure.io/freeipa/issue/8206
|
|
|
7e1b55 |
+ """
|
|
|
7e1b55 |
+
|
|
|
7e1b55 |
+ client = self.replicas[0]
|
|
|
7e1b55 |
+ # Configure firewall first
|
|
|
7e1b55 |
+ Firewall(client).enable_services(["freeipa-ldap",
|
|
|
7e1b55 |
+ "freeipa-ldaps"])
|
|
|
7e1b55 |
+
|
|
|
7e1b55 |
+ client.run_command(['ipa-client-install', '-U',
|
|
|
7e1b55 |
+ '--domain', self.master.domain.name,
|
|
|
7e1b55 |
+ '--realm', self.master.domain.realm,
|
|
|
7e1b55 |
+ '-p', 'admin',
|
|
|
7e1b55 |
+ '-w', self.master.config.admin_password,
|
|
|
7e1b55 |
+ '--server', self.master.hostname,
|
|
|
7e1b55 |
+ '--force-join'])
|
|
|
7e1b55 |
+
|
|
|
7e1b55 |
+ tasks.kinit_admin(client)
|
|
|
7e1b55 |
+
|
|
|
7e1b55 |
+ client.run_command(['ipa', 'host-mod', '--auth-ind=otp',
|
|
|
7e1b55 |
+ client.hostname])
|
|
|
7e1b55 |
+
|
|
|
7e1b55 |
+ res = client.run_command(['ipa-replica-install', '-U', '-w',
|
|
|
7e1b55 |
+ self.master.config.dirman_password],
|
|
|
7e1b55 |
+ raiseonerr=False)
|
|
|
7e1b55 |
+
|
|
|
7e1b55 |
+ client.run_command(['ipa', 'host-mod', '--auth-ind=',
|
|
|
7e1b55 |
+ client.hostname])
|
|
|
7e1b55 |
+
|
|
|
7e1b55 |
+ expected_err = ("Client cannot be promoted to a replica if the host "
|
|
|
7e1b55 |
+ "principal has an authentication indicator set.")
|
|
|
7e1b55 |
+ assert res.returncode == 1
|
|
|
7e1b55 |
+ assert expected_err in res.stderr_text
|
|
|
7e1b55 |
+
|
|
|
7e1b55 |
+
|
|
|
7e1b55 |
@replicas_cleanup
|
|
|
7e1b55 |
def test_one_command_installation(self):
|
|
|
7e1b55 |
"""
|
|
|
7e1b55 |
diff --git a/ipatests/test_xmlrpc/test_host_plugin.py b/ipatests/test_xmlrpc/test_host_plugin.py
|
|
|
7e1b55 |
index c66bbc865cd5e1ee5ee5e1874c177a3ea9b08c93..9cfde3565d48e103a0549e2bfb7579e07668f41b 100644
|
|
|
7e1b55 |
--- a/ipatests/test_xmlrpc/test_host_plugin.py
|
|
|
7e1b55 |
+++ b/ipatests/test_xmlrpc/test_host_plugin.py
|
|
|
7e1b55 |
@@ -605,6 +605,16 @@ class TestProtectedMaster(XMLRPC_test):
|
|
|
7e1b55 |
error=u'An IPA master host cannot be deleted or disabled')):
|
|
|
7e1b55 |
command()
|
|
|
7e1b55 |
|
|
|
7e1b55 |
+ def test_try_add_auth_ind_master(self, this_host):
|
|
|
7e1b55 |
+ command = this_host.make_update_command({
|
|
|
7e1b55 |
+ u'krbprincipalauthind': u'radius'})
|
|
|
7e1b55 |
+ with raises_exact(errors.ValidationError(
|
|
|
7e1b55 |
+ name='krbprincipalauthind',
|
|
|
7e1b55 |
+ error=u'authentication indicators not allowed '
|
|
|
7e1b55 |
+ 'in service "host"'
|
|
|
7e1b55 |
+ )):
|
|
|
7e1b55 |
+ command()
|
|
|
7e1b55 |
+
|
|
|
7e1b55 |
|
|
|
7e1b55 |
@pytest.mark.tier1
|
|
|
7e1b55 |
class TestValidation(XMLRPC_test):
|
|
|
7e1b55 |
diff --git a/ipatests/test_xmlrpc/test_service_plugin.py b/ipatests/test_xmlrpc/test_service_plugin.py
|
|
|
7e1b55 |
index 4c845938c33e2eca4235d53c4f4644c2fcdeda9c..ed634a0455a41dce367ed638634d1fc6d9e47553 100644
|
|
|
7e1b55 |
--- a/ipatests/test_xmlrpc/test_service_plugin.py
|
|
|
7e1b55 |
+++ b/ipatests/test_xmlrpc/test_service_plugin.py
|
|
|
7e1b55 |
@@ -25,6 +25,7 @@ from ipalib import api, errors
|
|
|
7e1b55 |
from ipatests.test_xmlrpc.xmlrpc_test import Declarative, fuzzy_uuid, fuzzy_hash
|
|
|
7e1b55 |
from ipatests.test_xmlrpc.xmlrpc_test import fuzzy_digits, fuzzy_date, fuzzy_issuer
|
|
|
7e1b55 |
from ipatests.test_xmlrpc.xmlrpc_test import fuzzy_hex, XMLRPC_test
|
|
|
7e1b55 |
+from ipatests.test_xmlrpc.xmlrpc_test import raises_exact
|
|
|
7e1b55 |
from ipatests.test_xmlrpc import objectclasses
|
|
|
7e1b55 |
from ipatests.test_xmlrpc.testcert import get_testcert, subject_base
|
|
|
7e1b55 |
from ipatests.test_xmlrpc.test_user_plugin import get_user_result, get_group_dn
|
|
|
7e1b55 |
@@ -1552,6 +1553,15 @@ def indicators_host(request):
|
|
|
7e1b55 |
return tracker.make_fixture(request)
|
|
|
7e1b55 |
|
|
|
7e1b55 |
|
|
|
7e1b55 |
+@pytest.fixture(scope='function')
|
|
|
7e1b55 |
+def this_host(request):
|
|
|
7e1b55 |
+ """Fixture for the current master"""
|
|
|
7e1b55 |
+ tracker = HostTracker(name=api.env.host.partition('.')[0],
|
|
|
7e1b55 |
+ fqdn=api.env.host)
|
|
|
7e1b55 |
+ tracker.exists = True
|
|
|
7e1b55 |
+ return tracker
|
|
|
7e1b55 |
+
|
|
|
7e1b55 |
+
|
|
|
7e1b55 |
@pytest.fixture(scope='function')
|
|
|
7e1b55 |
def indicators_service(request):
|
|
|
7e1b55 |
tracker = ServiceTracker(
|
|
|
7e1b55 |
@@ -1587,6 +1597,17 @@ class TestAuthenticationIndicators(XMLRPC_test):
|
|
|
7e1b55 |
expected_updates={u'krbprincipalauthind': [u'radius']}
|
|
|
7e1b55 |
)
|
|
|
7e1b55 |
|
|
|
7e1b55 |
+ def test_update_indicator_internal_service(self, this_host):
|
|
|
7e1b55 |
+ command = this_host.make_command('service_mod',
|
|
|
7e1b55 |
+ 'ldap/' + this_host.fqdn,
|
|
|
7e1b55 |
+ **dict(krbprincipalauthind='otp'))
|
|
|
7e1b55 |
+ with raises_exact(errors.ValidationError(
|
|
|
7e1b55 |
+ name='krbprincipalauthind',
|
|
|
7e1b55 |
+ error=u'authentication indicators not allowed '
|
|
|
7e1b55 |
+ 'in service "ldap"'
|
|
|
7e1b55 |
+ )):
|
|
|
7e1b55 |
+ command()
|
|
|
7e1b55 |
+
|
|
|
7e1b55 |
|
|
|
7e1b55 |
@pytest.fixture(scope='function')
|
|
|
7e1b55 |
def managing_host(request):
|
|
|
7e1b55 |
--
|
|
|
7e1b55 |
2.26.3
|
|
|
7e1b55 |
|