From dfbd7409111e44ddc09cd8143821746465756e33 Mon Sep 17 00:00:00 2001 From: Andrei Pavel Date: Fri, 20 Jun 2025 16:06:31 +0300 Subject: [PATCH] [#3907] NETCONF: Turn authentication.clients into a string just like hooks-libraries.parameters --- doc/examples/kea4/comments.json | 1 - doc/examples/kea6/comments.json | 1 - src/lib/yang/translator_control_socket.cc | 17 +++++++------ .../modules/hashes/kea-types@2025-06-25.hash | 2 +- .../yang/modules/kea-types@2025-06-25.yang | 25 +++---------------- 5 files changed, 13 insertions(+), 33 deletions(-) diff --git a/doc/examples/kea4/comments.json b/doc/examples/kea4/comments.json index 0762fd2298..3eab9dff0b 100644 --- a/doc/examples/kea4/comments.json +++ b/doc/examples/kea4/comments.json @@ -70,7 +70,6 @@ "type": "basic", // In basic HTTP authentication clients "clients": [ { - "comment": "admin is authorized", "user": "admin", "password": "1234" } ] diff --git a/doc/examples/kea6/comments.json b/doc/examples/kea6/comments.json index fdeb352bb8..0aa85d1872 100644 --- a/doc/examples/kea6/comments.json +++ b/doc/examples/kea6/comments.json @@ -70,7 +70,6 @@ "type": "basic", // In basic HTTP authentication clients "clients": [ { - "comment": "admin is authorized", "user": "admin", "password": "1234" } ] diff --git a/src/lib/yang/translator_control_socket.cc b/src/lib/yang/translator_control_socket.cc index b208f94b7b..e6bc9f7536 100644 --- a/src/lib/yang/translator_control_socket.cc +++ b/src/lib/yang/translator_control_socket.cc @@ -89,11 +89,12 @@ 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); @@ -134,7 +135,6 @@ TranslatorControlSocket::getControlSocketAuthenticationClient(DataNode const& da getMandatoryLeaf(result, data_node, "user-file"); getMandatoryLeaf(result, data_node, "password-file"); checkAndGetAndJsonifyLeaf(result, data_node, "user-context"); - return (result->empty() ? ElementPtr() : result); } @@ -239,8 +239,9 @@ TranslatorControlSocket::setControlSocketKea(string const& xpath, checkAndSetLeaf(authentication, xpath + "/authentication", "realm", LeafBaseType::String); checkAndSetLeaf(authentication, xpath + "/authentication", "directory", LeafBaseType::String); checkAndSetUserContext(authentication, xpath + "/authentication"); - ConstElementPtr clients = authentication->get("clients"); - setControlSocketAuthenticationClients(xpath + "/authentication/clients", clients); + checkAndStringifyAndSetLeaf(authentication, xpath + "/authentication", "clients"); + // ConstElementPtr clients = authentication->get("clients"); + // setControlSocketAuthenticationClients(xpath + "/authentication/clients", clients); } ConstElementPtr http_headers = elem->get("http-headers"); if (http_headers && !http_headers->empty()) { @@ -259,7 +260,6 @@ TranslatorControlSocket::setControlSocketAuthenticationClients(string const& xpa } for (size_t i = 0; i < elem->size(); ++i) { ElementPtr client = elem->getNonConst(i); - ostringstream key; auto user = client->get("user"); string user_str; if (user) { @@ -280,6 +280,7 @@ TranslatorControlSocket::setControlSocketAuthenticationClients(string const& xpa if (password_file) { password_file_str = password_file->stringValue(); } + ostringstream key; key << xpath << "[user='" << user_str << "'][password='" << password_str << "'][user-file='" << user_file_str << "'][password-file='" << password_file_str << "']"; diff --git a/src/share/yang/modules/hashes/kea-types@2025-06-25.hash b/src/share/yang/modules/hashes/kea-types@2025-06-25.hash index c708553205..c0feac4534 100644 --- a/src/share/yang/modules/hashes/kea-types@2025-06-25.hash +++ b/src/share/yang/modules/hashes/kea-types@2025-06-25.hash @@ -1 +1 @@ -b5f9e40815ea19641d64eefaf4acd429526e5f58c7ac8154fa89cd6c0033722e +7880835d105232e5575e324ec4db82481e7c07157adfe6028f4ec0949be1718f diff --git a/src/share/yang/modules/kea-types@2025-06-25.yang b/src/share/yang/modules/kea-types@2025-06-25.yang index 639baef170..13a35ca53a 100644 --- a/src/share/yang/modules/kea-types@2025-06-25.yang +++ b/src/share/yang/modules/kea-types@2025-06-25.yang @@ -138,28 +138,9 @@ module kea-types { grouping clients { description "HTTP client authentication."; - 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"; + leaf clients { + type string; + description "Clients (JSON value)."; } } -- 2.47.2