summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2011-05-12 12:12:45 +0100
committerMatthew Sackman <matthew@rabbitmq.com>2011-05-12 12:12:45 +0100
commit4077e54b43789827b92eec681ab15e60ff832023 (patch)
treea41d2440242fbc0f08aad7df0254596b310fe918
parent61349821a03d50016b4c73bf14d138970c1547ba (diff)
parentab8c1770d1a0e687e2e363b3d73cd9482640fd01 (diff)
downloadrabbitmq-server-4077e54b43789827b92eec681ab15e60ff832023.tar.gz
Merging bug23899 to default
-rw-r--r--src/rabbit_access_control.erl15
-rw-r--r--src/rabbit_direct.erl18
2 files changed, 10 insertions, 23 deletions
diff --git a/src/rabbit_access_control.erl b/src/rabbit_access_control.erl
index b0b57af4..59c00848 100644
--- a/src/rabbit_access_control.erl
+++ b/src/rabbit_access_control.erl
@@ -18,7 +18,7 @@
-include("rabbit.hrl").
--export([user_pass_login/2, check_user_pass_login/2, check_user_login/2,
+-export([check_user_pass_login/2, check_user_login/2,
check_vhost_access/2, check_resource_access/3, list_vhosts/2]).
%%----------------------------------------------------------------------------
@@ -30,9 +30,6 @@
-type(permission_atom() :: 'configure' | 'read' | 'write').
-type(vhost_permission_atom() :: 'read' | 'write').
--spec(user_pass_login/2 ::
- (rabbit_types:username(), rabbit_types:password())
- -> rabbit_types:user() | rabbit_types:channel_exit()).
-spec(check_user_pass_login/2 ::
(rabbit_types:username(), rabbit_types:password())
-> {'ok', rabbit_types:user()} | {'refused', string(), [any()]}).
@@ -49,16 +46,6 @@
%%----------------------------------------------------------------------------
-user_pass_login(User, Pass) ->
- ?LOGDEBUG("Login with user ~p pass ~p~n", [User, Pass]),
- case check_user_pass_login(User, Pass) of
- {refused, Msg, Args} ->
- rabbit_misc:protocol_error(
- access_refused, "login refused: ~s", [io_lib:format(Msg, Args)]);
- {ok, U} ->
- U
- end.
-
check_user_pass_login(Username, Password) ->
check_user_login(Username, [{password, Password}]).
diff --git a/src/rabbit_direct.erl b/src/rabbit_direct.erl
index 0dac18d1..7ff534ee 100644
--- a/src/rabbit_direct.erl
+++ b/src/rabbit_direct.erl
@@ -16,7 +16,7 @@
-module(rabbit_direct).
--export([boot/0, connect/5, start_channel/8, disconnect/1]).
+-export([boot/0, connect/4, start_channel/8, disconnect/1]).
-include("rabbit.hrl").
@@ -25,8 +25,8 @@
-ifdef(use_specs).
-spec(boot/0 :: () -> 'ok').
--spec(connect/5 :: (binary(), binary(), binary(), rabbit_types:protocol(),
- rabbit_event:event_props()) ->
+-spec(connect/4 :: (rabbit_types:username(), rabbit_types:vhost(),
+ rabbit_types:protocol(), rabbit_event:event_props()) ->
{'ok', {rabbit_types:user(),
rabbit_framing:amqp_table()}}).
-spec(start_channel/8 ::
@@ -53,11 +53,11 @@ boot() ->
%%----------------------------------------------------------------------------
-connect(Username, Password, VHost, Protocol, Infos) ->
+connect(Username, VHost, Protocol, Infos) ->
case lists:keymember(rabbit, 1, application:which_applications()) of
true ->
- try rabbit_access_control:user_pass_login(Username, Password) of
- #user{} = User ->
+ case rabbit_access_control:check_user_login(Username, []) of
+ {ok, User} ->
try rabbit_access_control:check_vhost_access(User, VHost) of
ok -> rabbit_event:notify(connection_created, Infos),
{ok, {User,
@@ -65,9 +65,9 @@ connect(Username, Password, VHost, Protocol, Infos) ->
catch
exit:#amqp_error{name = access_refused} ->
{error, access_refused}
- end
- catch
- exit:#amqp_error{name = access_refused} -> {error, auth_failure}
+ end;
+ {refused, _Msg, _Args} ->
+ {error, auth_failure}
end;
false ->
{error, broker_not_found_on_node}