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