diff options
author | Adam Kocoloski <kocolosk@apache.org> | 2019-09-16 16:27:12 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-16 16:27:12 -0400 |
commit | e0943b63d3b3b8814064903548e80b9b05fb2454 (patch) | |
tree | edae3930c1e79fd76fe03a097d1e7b0cff915a91 | |
parent | 7f78e3025a7a1e5a3f708e422638d1cd9d9611ab (diff) | |
parent | 196532f6847c195d1b7e614c8842c25962772b57 (diff) | |
download | couchdb-remove-old-multiquery.tar.gz |
Merge branch 'master' into remove-old-multiqueryremove-old-multiquery
-rw-r--r-- | src/couch_replicator/src/couch_replicator_auth.erl | 6 | ||||
-rw-r--r-- | src/couch_replicator/src/couch_replicator_docs.erl | 12 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/couch_replicator/src/couch_replicator_auth.erl b/src/couch_replicator/src/couch_replicator_auth.erl index 7f51cdd1c..272e10af5 100644 --- a/src/couch_replicator/src/couch_replicator_auth.erl +++ b/src/couch_replicator/src/couch_replicator_auth.erl @@ -33,6 +33,12 @@ % Behavior API +% Note for plugin developers: consider using the "auth" field in the source and +% target objects to store credentials. In that case non-owner and non-admin +% users will have those credentials stripped when they read the replication +% document, which mimicks the behavior for "headers" and user and pass fields +% in endpoint URLs". + -callback initialize(#httpdb{}) -> {ok, #httpdb{}, term()} | {error, term()} | ignore. diff --git a/src/couch_replicator/src/couch_replicator_docs.erl b/src/couch_replicator/src/couch_replicator_docs.erl index 2d6db1b73..81685cd48 100644 --- a/src/couch_replicator/src/couch_replicator_docs.erl +++ b/src/couch_replicator/src/couch_replicator_docs.erl @@ -683,8 +683,12 @@ strip_credentials(Url) when is_binary(Url) -> "http(s)?://(?:[^:]+):[^@]+@(.*)$", "http\\1://\\2", [{return, binary}]); -strip_credentials({Props}) -> - {lists:keydelete(<<"headers">>, 1, Props)}. +strip_credentials({Props0}) -> + Props1 = lists:keydelete(<<"headers">>, 1, Props0), + % Strip "auth" just like headers, for replication plugins it can be a place + % to stash credential that are not necessarily in headers + Props2 = lists:keydelete(<<"auth">>, 1, Props1), + {Props2}. error_reason({shutdown, Error}) -> @@ -773,6 +777,10 @@ check_strip_credentials_test() -> { {[{<<"_id">>, <<"foo">>}]}, {[{<<"_id">>, <<"foo">>}, {<<"headers">>, <<"baz">>}]} + }, + { + {[{<<"_id">>, <<"foo">>}]}, + {[{<<"_id">>, <<"foo">>}, {<<"auth">>, <<"pluginsecret">>}]} } ]]. |