]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3907] use strict format for clients in yang
authorRazvan Becheriu <razvan@isc.org>
Fri, 20 Jun 2025 13:44:36 +0000 (16:44 +0300)
committerRazvan Becheriu <razvan@isc.org>
Fri, 20 Jun 2025 13:44:36 +0000 (16:44 +0300)
src/lib/yang/translator_control_socket.cc
src/share/yang/modules/hashes/kea-types@2025-06-25.hash
src/share/yang/modules/kea-types@2025-06-25.yang

index e6bc9f75364dbd67de5589d262ca29a9de86c5a8..b1b9c3b1163b7d847eaa46796f9e7860cfcb9f80 100644 (file)
@@ -89,12 +89,11 @@ TranslatorControlSocket::getControlSocketKea(DataNode const& data_node) {
                         checkAndGetDivergingLeaf(authentication, node, "type", "auth-type");
                         checkAndGetLeaf(authentication, node, "realm");
                         checkAndGetLeaf(authentication, node, "directory");
-                        checkAndGetAndJsonifyLeaf(authentication, node, "clients");
                         checkAndGetAndJsonifyLeaf(authentication, node, "user-context");
-                        // ConstElementPtr clients = getControlSocketAuthenticationClients(node);
-                        // if (clients) {
-                        //     authentication->set("clients", clients);
-                        // }
+                        ConstElementPtr clients = getControlSocketAuthenticationClients(node);
+                        if (clients) {
+                            authentication->set("clients", clients);
+                        }
                         return (authentication);
                     });
         ConstElementPtr headers = getControlSocketHttpHeaders(data_node);
@@ -135,6 +134,18 @@ TranslatorControlSocket::getControlSocketAuthenticationClient(DataNode const& da
     getMandatoryLeaf(result, data_node, "user-file");
     getMandatoryLeaf(result, data_node, "password-file");
     checkAndGetAndJsonifyLeaf(result, data_node, "user-context");
+    if (result->get("user") && result->get("user")->stringValue().empty()) {
+        result->remove("user");
+    }
+    if (result->get("password") && result->get("password")->stringValue().empty()) {
+        result->remove("password");
+    }
+    if (result->get("user-file") && result->get("user-file")->stringValue().empty()) {
+        result->remove("user-file");
+    }
+    if (result->get("password-file") && result->get("password-file")->stringValue().empty()) {
+        result->remove("password-file");
+    }
     return (result->empty() ? ElementPtr() : result);
 }
 
@@ -239,9 +250,8 @@ TranslatorControlSocket::setControlSocketKea(string const& xpath,
             checkAndSetLeaf(authentication, xpath + "/authentication", "realm", LeafBaseType::String);
             checkAndSetLeaf(authentication, xpath + "/authentication", "directory", LeafBaseType::String);
             checkAndSetUserContext(authentication, xpath + "/authentication");
-            checkAndStringifyAndSetLeaf(authentication, xpath + "/authentication", "clients");
-            // ConstElementPtr clients = authentication->get("clients");
-            // setControlSocketAuthenticationClients(xpath + "/authentication/clients", clients);
+            ConstElementPtr clients = authentication->get("clients");
+            setControlSocketAuthenticationClients(xpath + "/authentication/clients", clients);
         }
         ConstElementPtr http_headers = elem->get("http-headers");
         if (http_headers && !http_headers->empty()) {
index c0feac45342a47dd6561f6e42847da02b5723274..c708553205135503aa60c3bacdace601d656c61f 100644 (file)
@@ -1 +1 @@
-7880835d105232e5575e324ec4db82481e7c07157adfe6028f4ec0949be1718f
+b5f9e40815ea19641d64eefaf4acd429526e5f58c7ac8154fa89cd6c0033722e
index 13a35ca53a1cb3aa1707cf3a8a701529f0d479e6..639baef170848db0629e24fde23477b5474d050c 100644 (file)
@@ -138,9 +138,28 @@ module kea-types {
 
   grouping clients {
     description "HTTP client authentication.";
-    leaf clients {
-      type string;
-      description "Clients (JSON value).";
+    list clients {
+      leaf user {
+        type string;
+        description "HTTP user.";
+      }
+      leaf password {
+        type string;
+        description "HTTP password.";
+      }
+      leaf user-file {
+        type string;
+        description "HTTP user file.";
+      }
+      leaf password-file {
+        type string;
+        description "HTTP password file.";
+      }
+      leaf user-context {
+        type user-context;
+        description "Logger user context.";
+      }
+      key "user password user-file password-file";
     }
   }