bb0ded
From 6d70421f57d0eca066a922e09416ef7195ee96d4 Mon Sep 17 00:00:00 2001
bb0ded
From: Julien Rische <jrische@redhat.com>
bb0ded
Date: Tue, 1 Feb 2022 16:43:09 +0100
bb0ded
Subject: [PATCH] ipa-kdb: do not remove keys for hardened auth-enabled users
bb0ded
bb0ded
Since 5d51ae5, principal keys were dropped in case user auth indicator
bb0ded
was not including password. Thereafter, the key removal behavior was
bb0ded
removed by 15ff9c8 in the context of the kdcpolicy plugin introduction.
bb0ded
Support for hardened pre-auth methods (FAST and SPAKE) was added in
bb0ded
d057040, and the removal of principal keys was restored afterwards by
bb0ded
f0d12b7, but not taking the new hardened auth indicator into account.
bb0ded
bb0ded
Fixes: https://pagure.io/freeipa/issue/9065
bb0ded
Related to: https://pagure.io/freeipa/issue/8001
bb0ded
bb0ded
Signed-off-by: Julien Rische <jrische@redhat.com>
bb0ded
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
bb0ded
Reviewed-By: Francisco Trivino <ftrivino@redhat.com>
bb0ded
---
bb0ded
 daemons/ipa-kdb/ipa_kdb_principals.c | 23 ++++++++++++-----------
bb0ded
 1 file changed, 12 insertions(+), 11 deletions(-)
bb0ded
bb0ded
diff --git a/daemons/ipa-kdb/ipa_kdb_principals.c b/daemons/ipa-kdb/ipa_kdb_principals.c
bb0ded
index 15f3df4fee8bdfadf60a4b1d9a5115407d1bb294..0d0d3748ce63a8252e84220d036140818ffdfb6e 100644
bb0ded
--- a/daemons/ipa-kdb/ipa_kdb_principals.c
bb0ded
+++ b/daemons/ipa-kdb/ipa_kdb_principals.c
bb0ded
@@ -788,17 +788,18 @@ static krb5_error_code ipadb_parse_ldap_entry(krb5_context kcontext,
bb0ded
                                       &res_key_data, &result, &mkvno);
bb0ded
     switch (ret) {
bb0ded
     case 0:
bb0ded
-        /* Only set a principal's key if password auth can be used. Otherwise
bb0ded
-         * the KDC would add pre-authentication methods to the NEEDED_PREAUTH
bb0ded
-         * reply for AS-REQs which indicate the password authentication is
bb0ded
-         * available. This might confuse applications like e.g. SSSD which try
bb0ded
-         * to determine suitable authentication methods and corresponding
bb0ded
-         * prompts with the help of MIT Kerberos' responder interface which
bb0ded
-         * acts on the returned pre-authentication methods. A typical example
bb0ded
-         * is enforced OTP authentication where of course keys are available
bb0ded
-         * for the first factor but password authentication should not be
bb0ded
-         * advertised by the KDC. */
bb0ded
-        if (!(ua & IPADB_USER_AUTH_PASSWORD) && (ua != IPADB_USER_AUTH_NONE)) {
bb0ded
+        /* Only set a principal's key if password or hardened auth can be used.
bb0ded
+         * Otherwise the KDC would add pre-authentication methods to the
bb0ded
+         * NEEDED_PREAUTH reply for AS-REQs which indicate the password
bb0ded
+         * authentication is available. This might confuse applications like
bb0ded
+         * e.g. SSSD which try to determine suitable authentication methods and
bb0ded
+         * corresponding prompts with the help of MIT Kerberos' responder
bb0ded
+         * interface which acts on the returned pre-authentication methods. A
bb0ded
+         * typical example is enforced OTP authentication where of course keys
bb0ded
+         * are available for the first factor but password authentication
bb0ded
+         * should not be advertised by the KDC. */
bb0ded
+        if (!(ua & (IPADB_USER_AUTH_PASSWORD | IPADB_USER_AUTH_HARDENED)) &&
bb0ded
+            (ua != IPADB_USER_AUTH_NONE)) {
bb0ded
             /* This is the same behavior as ENOENT below. */
bb0ded
             ipa_krb5_free_key_data(res_key_data, result);
bb0ded
             break;
bb0ded
-- 
bb0ded
2.34.1
bb0ded