Skip to content

Commit

Permalink
fix(mqtt): store password as a 0-arity function to prevent logging
Browse files Browse the repository at this point in the history
  • Loading branch information
paulswartz committed Oct 5, 2023
1 parent bc50cf8 commit b630edf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/state_mediator/lib/state_mediator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ defmodule StateMediator do
url: broker,
topic: app_value(State.Vehicle, :topic),
username: app_value(State.Vehicle, :username),
password: app_value(State.Vehicle, :password),
password: fn -> app_value(State.Vehicle, :password) end,
sync_timeout: 30_000
]
}
Expand Down
8 changes: 7 additions & 1 deletion apps/state_mediator/lib/state_mediator/mqtt_mediator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ defmodule StateMediator.MqttMediator do
end

defp configs_from_url(url, opts) do
password_opts =
password_value =
case opts[:password] do
fun when is_function(fun, 0) -> fun.()
other -> other
end

password_opts =
case password_value do
nil -> [[]]
[""] -> [[]]
passwords -> for password <- String.split(passwords, " "), do: [password: password]
Expand Down

0 comments on commit b630edf

Please sign in to comment.