c58629
From be18d6c15a2557e8f45e41efc81f1c005958c690 Mon Sep 17 00:00:00 2001
c58629
From: Stanislav Laznicka <slaznick@redhat.com>
c58629
Date: Tue, 7 Nov 2017 14:42:12 +0100
c58629
Subject: [PATCH] Don't allow OTP or RADIUS in FIPS mode
c58629
c58629
RADIUS, which is also internally used in the process of OTP
c58629
authentication by ipa-otpd, requires MD5 checksums which
c58629
makes it impossible to be used in FIPS mode. Don't allow users
c58629
setting OTP or RADIUS authentication if in FIPS mode.
c58629
c58629
https://pagure.io/freeipa/issue/7168
c58629
c58629
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
c58629
---
c58629
 ipaserver/plugins/baseuser.py |  3 +++
c58629
 ipaserver/plugins/config.py   | 16 ++++++++++++++++
c58629
 2 files changed, 19 insertions(+)
c58629
c58629
diff --git a/ipaserver/plugins/baseuser.py b/ipaserver/plugins/baseuser.py
c58629
index bf24dbf542d3b481671dfe4e8cee14a2edcc26e0..bb8a73ded0fed135d5829ec0b0829a936f2196fb 100644
c58629
--- a/ipaserver/plugins/baseuser.py
c58629
+++ b/ipaserver/plugins/baseuser.py
c58629
@@ -32,6 +32,7 @@ from .baseldap import (
c58629
     add_missing_object_class)
c58629
 from ipaserver.plugins.service import (
c58629
    validate_certificate, validate_realm, normalize_principal)
c58629
+from ipaserver.plugins.config import check_fips_auth_opts
c58629
 from ipalib.request import context
c58629
 from ipalib import _
c58629
 from ipalib.constants import PATTERN_GROUPUSER_NAME
c58629
@@ -477,6 +478,7 @@ class baseuser_add(LDAPCreate):
c58629
                             **options):
c58629
         assert isinstance(dn, DN)
c58629
         set_krbcanonicalname(entry_attrs)
c58629
+        check_fips_auth_opts(fips_mode=self.api.env.fips_mode, **options)
c58629
         self.obj.convert_usercertificate_pre(entry_attrs)
c58629
 
c58629
     def post_common_callback(self, ldap, dn, entry_attrs, *keys, **options):
c58629
@@ -600,6 +602,7 @@ class baseuser_mod(LDAPUpdate):
c58629
         assert isinstance(dn, DN)
c58629
         add_sshpubkey_to_attrs_pre(self.context, attrs_list)
c58629
 
c58629
+        check_fips_auth_opts(fips_mode=self.api.env.fips_mode, **options)
c58629
         self.check_namelength(ldap, **options)
c58629
 
c58629
         self.check_mail(entry_attrs)
c58629
diff --git a/ipaserver/plugins/config.py b/ipaserver/plugins/config.py
c58629
index ce15e6096f5b84dc45ee21d5aecc73ecf86eba07..c9033fa8e7a2a0bfe77464fa4f9c62278bd814f6 100644
c58629
--- a/ipaserver/plugins/config.py
c58629
+++ b/ipaserver/plugins/config.py
c58629
@@ -85,6 +85,20 @@ EXAMPLES:
c58629
 
c58629
 register = Registry()
c58629
 
c58629
+
c58629
+def check_fips_auth_opts(fips_mode, **options):
c58629
+    """
c58629
+    OTP and RADIUS are not allowed in FIPS mode since they use MD5
c58629
+    checksums (OTP uses our RADIUS responder daemon ipa-otpd).
c58629
+    """
c58629
+    if 'ipauserauthtype' in options and fips_mode:
c58629
+        if ('otp' in options['ipauserauthtype'] or
c58629
+                'radius' in options['ipauserauthtype']):
c58629
+            raise errors.InvocationError(
c58629
+                'OTP and RADIUS authentication in FIPS is '
c58629
+                'not yet supported')
c58629
+
c58629
+
c58629
 @register()
c58629
 class config(LDAPObject):
c58629
     """
c58629
@@ -398,6 +412,8 @@ class config_mod(LDAPUpdate):
c58629
 
c58629
     def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
c58629
         assert isinstance(dn, DN)
c58629
+        check_fips_auth_opts(fips_mode=self.api.env.fips_mode, **options)
c58629
+
c58629
         if 'ipadefaultprimarygroup' in entry_attrs:
c58629
             group=entry_attrs['ipadefaultprimarygroup']
c58629
             try:
c58629
-- 
c58629
2.13.6
c58629