%% @doc Handler for SASL-based authentication with Cassandra %% %% Authentication with cassandra can take any form, as long as it follows %% %% SASL principles. The actual implementation (what each message will contain) %% depends on the method used. Cassandra can be configured to use a certain class %% for authentication, and you can configure CQErl to use custom handler modules %% to match the server implementation. %% %% auth_init/3 will be called by CQErl upon receiving a %% request from the server to start authentication. Arguments are: %% %% %% Return type can be {reply, Reply :: binary(), State :: any()} or %% {close, Reason :: any()}. %% %% auth_handle_challenge/2 will be called every time a challenge %% is received from Cassandra. The arguments are the challenge (as binary()) %% and state. The return type is the same as auth_init. %% %% auth_handle_success/2 will be called when Cassandra indicates %% authentication success. The arguments are a final message sent along the sucess %% response (as binary()) and state. The return type can be ok %% or {close, Reason}. %% %% auth_handle_error/2 will be called when Cassandra replies with a %% authentication error. The arguments are a final message sent along the error %% response (as binary()) and state. The return value is not used. -module(cqerl_auth_handler). -type inet() :: {{byte(), byte(), byte(), byte()}, integer()} | %% IPv4 address {{byte(), byte(), byte(), byte(), %% IPv6 address byte(), byte(), byte(), byte(), byte(), byte(), byte(), byte(), byte(), byte(), byte(), byte()}, integer()}. -callback auth_init([any()], binary(), inet()) -> {reply, Response :: binary(), State :: any()} | {close, Reason :: any()}. -callback auth_handle_challenge(binary(), State :: any()) -> {reply, Response :: binary(), State :: any()} | {close, Reason :: any()}. -callback auth_handle_success(binary(), State :: any()) -> ok | {close, Reason :: any()}. -callback auth_handle_error(binary(), State :: any()) -> no_return().