Skip to content

Commit

Permalink
Merge pull request kafka4beam#109 from kafka4beam/fix-nested-wrapped-…
Browse files Browse the repository at this point in the history
…pass

fix: handle nested wrapped secrets
  • Loading branch information
thalesmg authored Dec 15, 2022
2 parents 9cec138 + 369303b commit 16ff7bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* 4.1.2
- Allow passwords passed down to `kpro_connection` to be multiply
nested functions, instead of considering at most a single layer.

* 4.1.1
- Ported changes from EMQX's fork (based on 2.3.6) back to master branch
- Included an pushback twards 'no_ack' callers. https://github.com/emqx/kafka_protocol/pull/1
Expand Down
10 changes: 6 additions & 4 deletions src/kpro_connection.erl
Original file line number Diff line number Diff line change
Expand Up @@ -598,10 +598,7 @@ hint_msg(_, _, _) ->
get_sasl_opt(Config) ->
case maps:get(sasl, Config, ?undef) of
{Mechanism, User, Pass0} when ?IS_PLAIN_OR_SCRAM(Mechanism) ->
Pass = case is_function(Pass0) of
true -> Pass0();
false -> Pass0
end,
Pass = unwrap_pass(Pass0),
{Mechanism, User, Pass};
{Mechanism, File} when ?IS_PLAIN_OR_SCRAM(Mechanism) ->
{User, Pass} = read_sasl_file(File),
Expand All @@ -610,6 +607,11 @@ get_sasl_opt(Config) ->
Other
end.

unwrap_pass(Fun) when is_function(Fun) ->
unwrap_pass(Fun());
unwrap_pass(Pass) ->
Pass.

%% Read a regular file, assume it has two lines:
%% First line is the sasl-plain username
%% Second line is the password
Expand Down

0 comments on commit 16ff7bb

Please sign in to comment.