0

我已经配置rabbitmq-auth-backend-http了,我的rabbitmq.config样子如下

[
  {rabbit, [{auth_backends, [rabbit_auth_backend_http, rabbit_auth_backend_internal]}]},
  {rabbitmq_auth_backend_http,
   [{http_method,   get},
    {user_path,     "http://localhost:8080/auth/user"},
    {vhost_path,    "http://localhost:8080/auth/vhost"},
    {resource_path, "http://localhost:8080/auth/resource"},
    {topic_path,    "http://localhost:8080/auth/topic"}]}
].

授权端点http://localhost:8080/auth已启动并正在运行。

但是当我尝试登录http://localhost:15672/api/whoamiapi 时,状态码为 500 失败。

使用 rabbitmq 内部数据库进行身份验证工作正常。rabbit_auth_backend_http唯一的问题是添加 auth_backends不起作用时。它甚至没有达到授权端点。我已经检查了登录var/rabbitmq/rabbit@localhost.log,但没有帮助。我在这里发布日志

=错误报告==== 2017 年 8 月 18 日::21:55:46 === 牧场侦听器 rabbit_web_dispatch_sup_15672 在 <0.574.0> 退出时使用 cowboy_protocol:start_link/4 启动了连接过程,原因是:{[{reason, undef},{mfa,{rabbit_mgmt_wm_whoami,is_authorized,2}},{stacktrace,[{rabbit_auth_backend_http,user_login_authentication,[<<"test">>,[{password,<<"test">>}]],[] },{rabbit_access_control,try_authenticate,3,[{file,"src/rabbit_access_control.erl"},{line,88}]},{rabbit_access_control,'-check_user_login/2-fun-0-',4,[{file ,"src/rabbit_access_control.erl"},{line,74}]},{lists,foldl,3,[{file,"lists.erl"},{line,1263}]},{rabbit_mgmt_util,is_authorized,6 ,[{file,"src/rabbit_mgmt_util.erl"},{line,149}]},{cowboy_rest,call,3,[{file,"src/cowboy_rest.erl"},{line,976}]},{cowboy_rest,is_authorized,2,[{file,"src/cowboy_rest.erl"},{line,150}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line ,442}]}]},{req,[{socket,#Port<0.26006>},{transport,ranch_tcp},{connection,keepalive},{pid,<0.574.0>},{method,<<" GET">>},{version,'HTTP/1.1'},{peer,{{127,0,0,1},51220}},{host,<<"localhost">>},{host_info,undefined },{port,15672},{path,<<"/api/whoami">>},{path_info,undefined},{qs,<<>>},{qs_vals,[]},{bindings,[] },{headers,[{<<"host">>,<<"localhost:15672">>},{<<"connection">>,<<"keep-alive">>},{<<"授权">>,<<"基本 dGVzdDp0ZXN0">>},{<<"用户代理">>,<<"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36">>},{<<"content-type">> ,<<"应用程序/json">>},{<<"接受">>,<<"/ ">>},{<<"referer">>,<<" http://localhost:15672/ ">>},{<<"accept-encoding">>,<<"gzip, deflate, br ">>},{<<"accept-language">>,<<"en-US,en;q=0.8">>},[{<<"connection">>,[<<"keep-alive ">>]}]},{cookies,undefined},{meta,[]},{body_state,waiting},{buffer,<<>>},{multipart,undefined},{resp_compress,true},{resp_state ,waiting},{resp_headers,[{<<"vary">>,<<"origin">>}]},{resp_body,<<>>},{onresponse,#Fun}]},{state,{上下文,未定义,无,未定义}}],[{cowboy_rest,error_terminate,5,[{file,"src/cowboy_rest.erl"},{line,1009}]},{cowboy_rest,is_authorized,2,[{file ,"src/cowboy_rest.erl"},{line,150}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,442}]}]}

我做错了什么?

谢谢你的帮助。

4

1 回答 1

0

发布这个问题rabbitmq-user谷歌组后,我得到了解决方案。您需要rabbitmq-auth-backend-http手动安装。在文件中添加配置rabbitmq.config不会安装它。

这是更详细答案的链接。

关于插件的另一件重要事情rabbitmq-auth-backend-http是您必须在文件中配置所有端点(user_path、vhost_path、topic_path、resource_path)rabbitmq.config。如果错过任何端点,rabbitmq 将采用低于默认值进行授权。

{user_path,     "http://localhost:8000/auth/user"},
{vhost_path,    "http://localhost:8000/auth/vhost"},
{resource_path, "http://localhost:8000/auth/resource"},
{topic_path,    "http://localhost:8000/auth/topic"}
于 2017-08-22T06:36:05.243 回答