This is an automated email from the ASF dual-hosted git repository.

yasithdev pushed a commit to branch pam-body-credentials
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git

commit 963db8e733360163d3380a58b6e3b0197dca7b5e
Author: Yasith Jayawardana <[email protected]>
AuthorDate: Thu Nov 5 01:53:12 2026 -0500

    Fix PAM body client credentials
---
 .../src/include/pam_oauth2_curl.cpp                | 10 +++++++---
 .../test/test_pam_oauth2_device.cpp                | 23 ++++++++++++----------
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/extensions/CILogon-SSH-PAM/src/include/pam_oauth2_curl.cpp 
b/extensions/CILogon-SSH-PAM/src/include/pam_oauth2_curl.cpp
index 940dd53fa..e72a30850 100644
--- a/extensions/CILogon-SSH-PAM/src/include/pam_oauth2_curl.cpp
+++ b/extensions/CILogon-SSH-PAM/src/include/pam_oauth2_curl.cpp
@@ -76,10 +76,14 @@ pam_oauth2_curl::call(Config const &config, const 
std::string &url,
                      std::vector<std::pair<std::string,std::string>> const 
&postdata)
 {
     call_data readBuffer;
-    std::string params{pam_oauth2_curl_impl::make_post_data(postdata)};
     impl_->reset(config);
     impl_->add_call_data(readBuffer);
     impl_->add_credential(readBuffer, make_credential(config));
+    pam_oauth2_curl::params fields{postdata};
+    for (auto const &kv : readBuffer.post_data)
+        if (std::none_of(fields.begin(), fields.end(), 
[&kv](std::pair<std::string,std::string> const &f) { return f.first == 
kv.first; }))
+            fields.push_back(kv);
+    std::string params{pam_oauth2_curl_impl::make_post_data(fields)};
     curl_easy_setopt(impl_->curl, CURLOPT_URL, url.c_str());
     curl_easy_setopt(impl_->curl, CURLOPT_POSTFIELDS, params.c_str());
     curl_easy_setopt(impl_->curl, CURLOPT_ERRORBUFFER, readBuffer.errbuf);
@@ -230,8 +234,8 @@ pam_oauth2_curl_impl::add_credential(call_data &data, 
pam_oauth2_curl::credentia
        case pam_oauth2_curl::credential::type::SECRET:
            // See RFC6749 section 2.3.1.
            // TODO: check if the connection is secure?
-           add_params(data.post_data, "client_id", encode(cred.un_));
-           add_params(data.post_data, "client_secret", encode(cred.pw_));
+           add_params(data.post_data, "client_id", data.cred.un_);
+           add_params(data.post_data, "client_secret", data.cred.pw_);
            break;
         case pam_oauth2_curl::credential::type::DENIED:
             throw NetworkError("default denied is not overridden");
diff --git a/extensions/CILogon-SSH-PAM/test/test_pam_oauth2_device.cpp 
b/extensions/CILogon-SSH-PAM/test/test_pam_oauth2_device.cpp
index c3b79bc77..a39f7ddd4 100644
--- a/extensions/CILogon-SSH-PAM/test/test_pam_oauth2_device.cpp
+++ b/extensions/CILogon-SSH-PAM/test/test_pam_oauth2_device.cpp
@@ -40,16 +40,19 @@ TEST(PamTest, Device)
 
 TEST(PamTest, Token)
 {
-    Config config;
-    config.client_id = CLIENT_ID;
-    config.client_secret = CLIENT_SECRET;
-    config.http_basic_auth = true;
-    pam_oauth2_log logger(nullptr, pam_oauth2_log::log_level_t::OFF);
-    std::string token;
-    poll_for_token(config, logger, CLIENT_ID, CLIENT_SECRET,
-                   TOKEN_ENDPOINT,
-                   DEVICE_CODE, token);
-    EXPECT_EQ(token, ACCESS_TOKEN);
+    for (bool basic : {true, false})
+    {
+        Config config;
+        config.client_id = CLIENT_ID;
+        config.client_secret = CLIENT_SECRET;
+        config.http_basic_auth = basic;
+        pam_oauth2_log logger(nullptr, pam_oauth2_log::log_level_t::OFF);
+        std::string token;
+        poll_for_token(config, logger, CLIENT_ID, CLIENT_SECRET,
+                       TOKEN_ENDPOINT,
+                       DEVICE_CODE, token);
+        EXPECT_EQ(token, ACCESS_TOKEN) << "http_basic_auth=" << basic;
+    }
 }
 
 TEST(PamTest, Userinfo)

Reply via email to