Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brod supports sasl credentials from file #135

Merged
merged 4 commits into from
Jan 3, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions lib/broadway_kafka/brod_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,25 @@ defmodule BroadwayKafka.BrodClient do
defp validate_option(:sasl, value = {:callback, _callback_module, _opts}),
do: {:ok, value}

defp validate_option(:sasl, {mechanism, username, password} = value)
when mechanism in [:plain, :scram_sha_256, :scram_sha_512] and
is_binary(username) and
is_binary(password) do
{:ok, value}
end

defp validate_option(:sasl, {mechanism, path} = value)
when mechanism in [:plain, :scram_sha_256, :scram_sha_512] and
is_binary(path) do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To they actually allow the path to be a binary or must it be an Erlang string (i.e. Elixir charlist?)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have it working as binary, I'm not sure if it allows a charlist, do you want me to check? I'm following the same typing approach as the existing username/password

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it works as a binary, that's all we need.

{:ok, value}
end

defp validate_option(:sasl, value) do
with {mechanism, username, password}
when mechanism in [:plain, :scram_sha_256, :scram_sha_512] and
is_binary(username) and
is_binary(password) <- value do
{:ok, value}
else
_value -> validation_error(:sasl, "a tuple of SASL mechanism, username and password", value)
end
validation_error(
:sasl,
"a tuple of SASL mechanism, username and password, or mechanism and path",
value
)
end

defp validate_option(:query_api_versions, value) when not is_boolean(value),
Expand Down
Loading