You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2026/09/30 10:40:18 UTC

(couchdb) 01/01: Match IBM's existing IAM auth plugin more closely.

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

rnewson pushed a commit to branch ibm-iam-auth-api
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 4702c658de50e513d4fd7661410c204989c7e35f
Author: Robert Newson <rn...@apache.org>
AuthorDate: Wed Sep 30 11:38:42 2026 +0100

    Match IBM's existing IAM auth plugin more closely.
    
    This makes it match the IBM plugin, just nested under the "ibm"
    vendor object. This will make it easier to configure Cloudant and
    CouchDB systems.
---
 .../src/couch_replicator_auth_ibm.erl                 | 19 ++++++++++++++-----
 src/docs/src/replication/replicator.rst               |  6 ++++--
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/couch_replicator/src/couch_replicator_auth_ibm.erl b/src/couch_replicator/src/couch_replicator_auth_ibm.erl
index ed17080a0..1c8480a65 100644
--- a/src/couch_replicator/src/couch_replicator_auth_ibm.erl
+++ b/src/couch_replicator/src/couch_replicator_auth_ibm.erl
@@ -391,9 +391,14 @@ now_secs() ->
 extract_api_key(#httpdb{auth_props = AuthProps}) ->
     case proplists:get_value(~"ibm", AuthProps) of
         {IBMProps} when is_list(IBMProps) ->
-            case proplists:get_value(~"apikey", IBMProps) of
-                APIKey when is_binary(APIKey), byte_size(APIKey) > 0 ->
-                    {ok, APIKey};
+            case proplists:get_value(~"iam", IBMProps) of
+                {IAMProps} when is_list(IAMProps) ->
+                    case proplists:get_value(~"api_key", IAMProps) of
+                        APIKey when is_binary(APIKey), byte_size(APIKey) > 0 ->
+                            {ok, APIKey};
+                        _ ->
+                            {error, missing_api_key}
+                    end;
                 _ ->
                     {error, missing_api_key}
             end;
@@ -541,7 +546,9 @@ retry_ms() ->
 extract_api_key_test() ->
     ?assertEqual(
         {ok, ~"fake_api_key"},
-        extract_api_key(#httpdb{auth_props = [{~"ibm", {[{~"apikey", ~"fake_api_key"}]}}]})
+        extract_api_key(#httpdb{
+            auth_props = [{~"ibm", {[{~"iam", {[{~"api_key", ~"fake_api_key"}]}}]}}]
+        })
     ),
     ?assertEqual({error, missing_api_key}, extract_api_key(#httpdb{auth_props = []})).
 
@@ -594,7 +601,9 @@ test_get_token(_) ->
 test_initialize(_) ->
     ?_test(
         begin
-            HttpDb = #httpdb{auth_props = [{~"ibm", {[{~"apikey", ~"fake_api_key"}]}}]},
+            HttpDb = #httpdb{
+                auth_props = [{~"ibm", {[{~"iam", {[{~"api_key", ~"fake_api_key"}]}}]}}]
+            },
             Result2 = initialize(HttpDb),
             ?assertMatch(
                 {ok, HttpDb, #worker_state{api_key_mac = MAC}} when is_binary(MAC), Result2
diff --git a/src/docs/src/replication/replicator.rst b/src/docs/src/replication/replicator.rst
index 92a74f612..e3ae9e2ce 100644
--- a/src/docs/src/replication/replicator.rst
+++ b/src/docs/src/replication/replicator.rst
@@ -823,8 +823,10 @@ your source or target as follows;
                 "url": "http://someurl.com/mydb",
                 "auth": {
                     "ibm": {
-                        "apikey": "$apikey"
-                     }
+                        "iam": {
+                            "api_key": "$apikey"
+                        }
+                    }
                 }
             },
             ...