diff options
| -rw-r--r-- | docs/rabbitmqctl.1.xml | 27 | ||||
| -rw-r--r-- | src/rabbit_cli.erl | 6 | ||||
| -rw-r--r-- | src/rabbit_control_main.erl | 5 | ||||
| -rw-r--r-- | src/rabbit_ctl_misc.erl | 31 |
4 files changed, 69 insertions, 0 deletions
diff --git a/docs/rabbitmqctl.1.xml b/docs/rabbitmqctl.1.xml index 43d00418e6..b60e4f02ab 100644 --- a/docs/rabbitmqctl.1.xml +++ b/docs/rabbitmqctl.1.xml @@ -722,6 +722,33 @@ </varlistentry> <varlistentry> + <term> + <cmdsynopsis> + <command>authenticate_user</command> <arg choice="req"><replaceable>username</replaceable></arg> <arg choice="req"><replaceable>password</replaceable></arg> + </cmdsynopsis> + </term> + <listitem> + <variablelist> + <varlistentry> + <term>username</term> + <listitem><para>The name of the user.</para></listitem> + </varlistentry> + <varlistentry> + <term>password</term> + <listitem><para>The password of the user.</para></listitem> + </varlistentry> + </variablelist> + <para role="example-prefix">For example:</para> + <screen role="example">rabbitmqctl authenticate_user tonyg verifyit</screen> + <para role="example"> + This command instructs the RabbitMQ broker to authenticate the + user named <command>tonyg</command> with password + <command>verifyit</command>. + </para> + </listitem> + </varlistentry> + + <varlistentry> <term><cmdsynopsis><command>set_user_tags</command> <arg choice="req"><replaceable>username</replaceable></arg> <arg choice="req"><replaceable>tag</replaceable> ...</arg></cmdsynopsis></term> <listitem> <variablelist> diff --git a/src/rabbit_cli.erl b/src/rabbit_cli.erl index 33098ce16b..1dfbb11b2a 100644 --- a/src/rabbit_cli.erl +++ b/src/rabbit_cli.erl @@ -66,6 +66,9 @@ main(ParseFun, DoFun, UsageMod) -> case catch DoFun(Command, Node, Args, Opts) of ok -> rabbit_misc:quit(0); + {ok, Result} -> + rabbit_ctl_misc:print_cmd_result(Command, Result), + rabbit_misc:quit(0); {'EXIT', {function_clause, [{?MODULE, action, _} | _]}} -> %% < R15 PrintInvalidCommandError(), usage(UsageMod); @@ -106,6 +109,9 @@ main(ParseFun, DoFun, UsageMod) -> print_error("unable to connect to nodes ~p: ~w", [Nodes, Reason]), print_badrpc_diagnostics(Nodes), rabbit_misc:quit(2); + {refused, Username, _, _} -> + print_error("failed to authenticate user \"~s\"", [Username]), + rabbit_misc:quit(2); Other -> print_error("~p", [Other]), rabbit_misc:quit(2) diff --git a/src/rabbit_control_main.erl b/src/rabbit_control_main.erl index c988ff1a49..1d98e5a354 100644 --- a/src/rabbit_control_main.erl +++ b/src/rabbit_control_main.erl @@ -52,6 +52,7 @@ delete_user, change_password, clear_password, + authenticate_user, set_user_tags, list_users, @@ -379,6 +380,10 @@ action(clear_password, Node, Args = [Username], _Opts, Inform) -> Inform("Clearing password for user \"~s\"", [Username]), call(Node, {rabbit_auth_backend_internal, clear_password, Args}); +action(authenticate_user, Node, Args = [Username, _Password], _Opts, Inform) -> + Inform("Authenticating user \"~s\"", [Username]), + call(Node, {rabbit_access_control, check_user_pass_login, Args}); + action(set_user_tags, Node, [Username | TagsStr], _Opts, Inform) -> Tags = [list_to_atom(T) || T <- TagsStr], Inform("Setting tags for user \"~s\" to ~p", [Username, Tags]), diff --git a/src/rabbit_ctl_misc.erl b/src/rabbit_ctl_misc.erl new file mode 100644 index 0000000000..92ae111028 --- /dev/null +++ b/src/rabbit_ctl_misc.erl @@ -0,0 +1,31 @@ +%% The contents of this file are subject to the Mozilla Public License +%% Version 1.1 (the "License"); you may not use this file except in +%% compliance with the License. You may obtain a copy of the License +%% at http://www.mozilla.org/MPL/ +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and +%% limitations under the License. +%% +%% The Original Code is RabbitMQ. +%% +%% The Initial Developer of the Original Code is GoPivotal, Inc. +%% Copyright (c) 2007-2015 Pivotal Software, Inc. All rights reserved. +%% + +-module(rabbit_ctl_misc). + +-export([print_cmd_result/2]). + +%%---------------------------------------------------------------------------- + +-ifdef(use_specs). + +-spec(print_cmd_result/2 :: (atom(), term()) -> string()). + +-endif. + +%%---------------------------------------------------------------------------- + +print_cmd_result(authenticate_user, _Result) -> io:format("Success~n"). |
