【问题标题】:Rabbit MQ backend http authorisation not workingRabbit MQ后端http授权不起作用
【发布时间】:2017-08-18 17:09:49
【问题描述】:

我已经配置了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/whoami 时,api 失败,状态码为 500。

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

=错误报告==== 2017 年 8 月 18 日::21:55:46 === 牧场侦听器 rabbit_web_dispatch_sup_15672 在 退出时使用 cowboy_protocol:start_link/4 开始了连接过程,原因是:{[{reason,undef},{mfa,{rabbit_mgmt_wm_whoami,is_authorized,2}},{stacktrace,[{rabbit_auth_backend_http, user_login_authentication,[>,[{password,>}]],[]},{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}, {transport,ranch_tcp},{connection,keepalive},{pid,},{method,>},{version,'HTTP/1.1'},{peer,{{127 ,0,0,1 },51220}},{host,>},{host_info,undefined},{port,15672},{path,>},{path_info,undefined} ,{qs,>},{qs_vals,[]},{bindings,[]},{headers,[{>,>},{>,>},{>,>},{>,>},{>,>}, {>,/">>},{>,http://localhost:15672/">>},{>,>},{>,>},[{>,[>]}]},{cookies,undefined},{meta,[]},{body_state,waiting},{buffer,>}, {multipart,undefined},{resp_compress,true},{resp_state,waiting},{resp_headers,[{>,>}]},{resp_body,>} ,{onresponse,#Fun}]},{state,{context,undefined,none,undefined}}],[{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}]}]}

我做错了什么?

感谢您的帮助。

【问题讨论】:

    标签: rabbitmq authorization messagebroker rabbitmqadmin


    【解决方案1】:

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

    这里是更多detailed answer的链接。

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

    {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"}
    

    【讨论】:

      猜你喜欢
      • 2018-07-24
      • 1970-01-01
      • 2017-12-20
      • 1970-01-01
      • 2012-04-24
      • 2015-08-09
      • 2015-06-04
      • 2021-12-20
      • 1970-01-01
      相关资源
      最近更新 更多