diff options
| author | Francesco Mazzoli <francesco@rabbitmq.com> | 2012-03-05 18:55:21 +0000 |
|---|---|---|
| committer | Francesco Mazzoli <francesco@rabbitmq.com> | 2012-03-05 18:55:21 +0000 |
| commit | 33f0fe96678cac4c4114e825d1627db3384802a3 (patch) | |
| tree | db28f0f255d453806d8aa9e69e80e7549ba73f95 /src | |
| parent | 82f9e3ef6024ef7c230b0896ea5393df72c9345e (diff) | |
| download | rabbitmq-server-git-33f0fe96678cac4c4114e825d1627db3384802a3.tar.gz | |
Added -callbacks for rabbit_auth_mechanism.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_auth_mechanism.erl | 56 | ||||
| -rw-r--r-- | src/rabbit_auth_mechanism_amqplain.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_auth_mechanism_cr_demo.erl | 2 | ||||
| -rw-r--r-- | src/rabbit_auth_mechanism_plain.erl | 2 |
4 files changed, 33 insertions, 29 deletions
diff --git a/src/rabbit_auth_mechanism.erl b/src/rabbit_auth_mechanism.erl index 0c8251b803..eda6a74305 100644 --- a/src/rabbit_auth_mechanism.erl +++ b/src/rabbit_auth_mechanism.erl @@ -16,31 +16,41 @@ -module(rabbit_auth_mechanism). +-ifdef(use_specs). + +%% A description. +-callback description() -> [proplist:property()]. + +%% If this mechanism is enabled, should it be offered for a given socket? +%% (primarily so EXTERNAL can be SSL-only) +-callback should_offer(rabbit_net:socket()) -> boolean(). + +%% Called before authentication starts. Should create a state +%% object to be passed through all the stages of authentication. +-callback init(rabbit_net:socket()) -> any(). + +%% Handle a stage of authentication. Possible responses: +%% {ok, User} +%% Authentication succeeded, and here's the user record. +%% {challenge, Challenge, NextState} +%% Another round is needed. Here's the state I want next time. +%% {protocol_error, Msg, Args} +%% Client got the protocol wrong. Log and die. +%% {refused, Msg, Args} +%% Client failed authentication. Log and die. +-callback handle_response(binary(), any()) -> + {'ok', rabbit_types:user()} | + {'challenge', binary(), any()} | + {'protocol_error', string(), [any()]} | + {'refused', string(), [any()]}. + +-else. + -export([behaviour_info/1]). behaviour_info(callbacks) -> - [ - %% A description. - {description, 0}, - - %% If this mechanism is enabled, should it be offered for a given socket? - %% (primarily so EXTERNAL can be SSL-only) - {should_offer, 1}, - - %% Called before authentication starts. Should create a state - %% object to be passed through all the stages of authentication. - {init, 1}, - - %% Handle a stage of authentication. Possible responses: - %% {ok, User} - %% Authentication succeeded, and here's the user record. - %% {challenge, Challenge, NextState} - %% Another round is needed. Here's the state I want next time. - %% {protocol_error, Msg, Args} - %% Client got the protocol wrong. Log and die. - %% {refused, Msg, Args} - %% Client failed authentication. Log and die. - {handle_response, 2} - ]; + [{description, 0}, {should_offer, 1}, {init, 1}, {handle_response, 2}]; behaviour_info(_Other) -> undefined. + +-endif. diff --git a/src/rabbit_auth_mechanism_amqplain.erl b/src/rabbit_auth_mechanism_amqplain.erl index 3de6e7a679..c0d86cd1b7 100644 --- a/src/rabbit_auth_mechanism_amqplain.erl +++ b/src/rabbit_auth_mechanism_amqplain.erl @@ -21,8 +21,6 @@ -export([description/0, should_offer/1, init/1, handle_response/2]). --include("rabbit_auth_mechanism_spec.hrl"). - -rabbit_boot_step({?MODULE, [{description, "auth mechanism amqplain"}, {mfa, {rabbit_registry, register, diff --git a/src/rabbit_auth_mechanism_cr_demo.erl b/src/rabbit_auth_mechanism_cr_demo.erl index 64b01d8e5d..5df1d5d799 100644 --- a/src/rabbit_auth_mechanism_cr_demo.erl +++ b/src/rabbit_auth_mechanism_cr_demo.erl @@ -21,8 +21,6 @@ -export([description/0, should_offer/1, init/1, handle_response/2]). --include("rabbit_auth_mechanism_spec.hrl"). - -rabbit_boot_step({?MODULE, [{description, "auth mechanism cr-demo"}, {mfa, {rabbit_registry, register, diff --git a/src/rabbit_auth_mechanism_plain.erl b/src/rabbit_auth_mechanism_plain.erl index 19fb587567..423170e147 100644 --- a/src/rabbit_auth_mechanism_plain.erl +++ b/src/rabbit_auth_mechanism_plain.erl @@ -21,8 +21,6 @@ -export([description/0, should_offer/1, init/1, handle_response/2]). --include("rabbit_auth_mechanism_spec.hrl"). - -rabbit_boot_step({?MODULE, [{description, "auth mechanism plain"}, {mfa, {rabbit_registry, register, |
