Skip to content

Commit

Permalink
fix: error message during md5 auth (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
abc3 authored Oct 10, 2023
1 parent e6e4cdf commit 9a19132
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.9
0.9.10
13 changes: 10 additions & 3 deletions lib/supavisor/client_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,15 @@ defmodule Supavisor.ClientHandler do

case handle_exchange(sock, {method, secrets}) do
{:error, reason} ->
Logger.error("Exchange error: #{inspect(reason)}")
msg = Server.exchange_message(:final, "e=#{reason}")
Logger.error("Exchange error: #{inspect(reason)} when method #{inspect(method)}")

msg =
if method == :auth_query_md5 do
Server.error_message("XX000", reason)
else
Server.exchange_message(:final, "e=#{reason}")
end

sock_send(sock, msg)

{:stop, :normal, data}
Expand Down Expand Up @@ -518,7 +525,7 @@ defmodule Supavisor.ClientHandler do
end

defp authenticate_exchange(:auth_query, secrets, signatures, p) do
client_key = :crypto.exor(p |> Base.decode64!(), signatures.client)
client_key = :crypto.exor(Base.decode64!(p), signatures.client)

if H.hash(client_key) == secrets.().stored_key do
{:ok, client_key}
Expand Down

0 comments on commit 9a19132

Please sign in to comment.