summaryrefslogtreecommitdiff
path: root/src/rabbit_direct.erl
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-02-05 13:16:41 +0000
committerSimon MacMullen <simon@rabbitmq.com>2014-02-05 13:16:41 +0000
commit0cb1a2e5df3f1c9c2b0346d97ad7c4c17495106f (patch)
tree82d0072794114dfd35b3d41971e008511d67ff6c /src/rabbit_direct.erl
parent1da40fe4d737f507f38c000e85bcd7f067bef4eb (diff)
downloadrabbitmq-server-0cb1a2e5df3f1c9c2b0346d97ad7c4c17495106f.tar.gz
Introduce dummy user for direct connections without users.
Diffstat (limited to 'src/rabbit_direct.erl')
-rw-r--r--src/rabbit_direct.erl28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/rabbit_direct.erl b/src/rabbit_direct.erl
index 5a004792..267b581d 100644
--- a/src/rabbit_direct.erl
+++ b/src/rabbit_direct.erl
@@ -31,7 +31,7 @@
-spec(force_event_refresh/0 :: () -> 'ok').
-spec(list/0 :: () -> [pid()]).
-spec(list_local/0 :: () -> [pid()]).
--spec(connect/5 :: ((rabbit_types:username() | rabbit_types:user() |
+-spec(connect/5 :: (('nouser' |
{rabbit_types:username(), rabbit_types:password()}),
rabbit_types:vhost(), rabbit_types:protocol(), pid(),
rabbit_event:event_props()) ->
@@ -67,37 +67,35 @@ list() ->
%%----------------------------------------------------------------------------
-connect(User = #user{}, VHost, Protocol, Pid, Infos) ->
- try rabbit_access_control:check_vhost_access(User, VHost) of
- ok -> ok = pg_local:join(rabbit_direct, Pid),
- rabbit_event:notify(connection_created, Infos),
- {ok, {User, rabbit_reader:server_properties(Protocol)}}
- catch
- exit:#amqp_error{name = access_refused} ->
- {error, access_refused}
- end;
-
connect({Username, Password}, VHost, Protocol, Pid, Infos) ->
connect0(fun () -> rabbit_access_control:check_user_pass_login(
Username, Password) end,
VHost, Protocol, Pid, Infos);
-connect(Username, VHost, Protocol, Pid, Infos) ->
- connect0(fun () -> rabbit_access_control:check_user_login(
- Username, []) end,
+connect(nouser, VHost, Protocol, Pid, Infos) ->
+ connect0(fun () -> {ok, rabbit_auth_backend_dummy:user()} end,
VHost, Protocol, Pid, Infos).
connect0(AuthFun, VHost, Protocol, Pid, Infos) ->
case rabbit:is_running() of
true -> case AuthFun() of
{ok, User} ->
- connect(User, VHost, Protocol, Pid, Infos);
+ connect1(User, VHost, Protocol, Pid, Infos);
{refused, _M, _A} ->
{error, {auth_failure, "Refused"}}
end;
false -> {error, broker_not_found_on_node}
end.
+connect1(User, VHost, Protocol, Pid, Infos) ->
+ try rabbit_access_control:check_vhost_access(User, VHost) of
+ ok -> ok = pg_local:join(rabbit_direct, Pid),
+ rabbit_event:notify(connection_created, Infos),
+ {ok, {User, rabbit_reader:server_properties(Protocol)}}
+ catch
+ exit:#amqp_error{name = access_refused} ->
+ {error, access_refused}
+ end.
start_channel(Number, ClientChannelPid, ConnPid, ConnName, Protocol, User,
VHost, Capabilities, Collector) ->