Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.8.3
2.8.4
3 changes: 1 addition & 2 deletions lib/supavisor/client_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ defmodule Supavisor.ClientHandler do
# Authentication timeout handler
def handle_event(:timeout, :auth_timeout, auth_state, data)
when auth_state in [:auth_md5_wait, :auth_scram_first_wait, :auth_scram_final_wait] do
handle_auth_failure(data.sock, {:timeout, auth_state}, data, auth_state)
handle_auth_failure(data.sock, :timeout, data, auth_state)
end

def handle_event(:enter, old_state, new_state, data) do
Expand Down Expand Up @@ -830,7 +830,6 @@ defmodule Supavisor.ClientHandler do
)

Supavisor.CircuitBreaker.record_failure({data.tenant, data.peer_ip}, :auth_error)

Error.maybe_log_and_send_error(sock, {:error, :auth_error, reason, data.user}, context)
Telem.client_join(:fail, data.id)
{:stop, :normal}
Expand Down
34 changes: 18 additions & 16 deletions lib/supavisor/client_handler/error.ex
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,19 @@ defmodule Supavisor.ClientHandler.Error do
}
end

defp process({:error, :auth_error, {:timeout, _message}, _user}, _context) do
defp process({:error, :auth_error, :timeout, _user}, context) do
%{
error: Server.error_message("08006", "connection failure during authentication")
error: Server.error_message("08006", "connection failure during authentication"),
log_message:
"Timeout while waiting for message in state #{auth_context_description(context)}"
}
end

defp process({:error, :auth_error, {:unexpected_message, _details}, _user}, _context) do
defp process({:error, :auth_error, {:unexpected_message, details}, _user}, context) do
%{
error: Server.error_message("08P01", "protocol violation during authentication")
error: Server.error_message("08P01", "protocol violation during authentication"),
log_message:
"#{auth_context_description(context)} unexpected message during authentication: #{inspect(details)}"
}
end

Expand All @@ -153,18 +157,11 @@ defmodule Supavisor.ClientHandler.Error do
}
end

defp process({:error, :auth_error, {:timeout, _}}, context) do
log_message =
case context do
:auth_md5_wait -> "Timeout while waiting for MD5 password"
:auth_scram_first_wait -> "Timeout while waiting for first SCRAM message"
:auth_scram_final_wait -> "Timeout while waiting for final SCRAM message"
_ -> "Authentication timeout"
end

defp process({:error, :auth_error, :timeout}, context) do
%{
error: Server.error_message("08006", "connection failure during authentication"),
log_message: log_message
log_message:
"Timeout while waiting for message in state #{auth_context_description(context)}"
}
end

Expand All @@ -179,9 +176,13 @@ defmodule Supavisor.ClientHandler.Error do
}
end

defp process({:error, :auth_error, reason}, _context) do
defp process({:error, :auth_error, reason}, context) do
message =
"Authentication error, reason: #{inspect(reason)}, context: #{auth_context_description(context)}"

%{
error: Server.error_message("XX000", "Authentication error, reason: #{inspect(reason)}")
error: Server.error_message("XX000", message),
log_message: message
}
end

Expand Down Expand Up @@ -273,6 +274,7 @@ defmodule Supavisor.ClientHandler.Error do
}
end

defp auth_context_description(:handshake), do: "Handshake"
defp auth_context_description(:auth_md5_wait), do: "MD5"
defp auth_context_description(:auth_scram_first_wait), do: "SCRAM first"
defp auth_context_description(:auth_scram_final_wait), do: "SCRAM final"
Expand Down
Loading