rabbitmq / rabbitmq-auth-backend-http

HTTP-based authorisation and authentication for RabbitMQ
Other
199 stars 72 forks source link

Address function_clause error #100

Closed lukebakken closed 4 years ago

lukebakken commented 4 years ago

https://pivotal-esc.atlassian.net/browse/VESC-974

A user's valid vhosts can't be established due to a swallowed function_clause error in this plugin. Stack trace:

{'EXIT',{function_clause,[{rabbit_auth_backend_http,check_vhost_access,[{auth_user,<<"lbakken">>,[management],none},<<"VESC974">>,undefined],[{file,"src/rabbit_auth_backend_http.erl"},{line,62}]},{rabbit_access_control,check_access,5,[{file,"src/rabbit_access_control.erl"},{line,221}]},{lists,foldl,3,[{file,"lists.erl"},{line,1263}]},{rabbit_mgmt_util,'-list_login_vhosts_names/2-lc$^2/1-0-',3,[{file,"src/rabbit_mgmt_util.erl"},{line,1092}]},{rabbit_mgmt_wm_vhosts,to_json,2,[{file,"src/rabbit_mgmt_wm_vhosts.erl"},{line,44}]},{cowboy_rest,call,3,[{file,"src/cowboy_rest.erl"},{line,1576}]},{cowboy_rest,set_resp_body,2,[{file,"src/cowboy_rest.erl"},{line,1466}]},{cowboy_rest,upgrade,4,[{file,"src/cowboy_rest.erl"},{line,288}]}]}}

Introduced by this commit -

https://github.com/rabbitmq/rabbitmq-auth-backend-http/commit/b2ad3c71694330918228eaf9d9b692963d04a617

This must be a very unique combination of using this plugin and having multiple vhosts, only a subset of which a user has access to. Otherwise I would expect it to have been reported by now.

lukebakken commented 4 years ago

@michaelklishin I admit I'm a bit surprised to see we catch from check_vhost_access but not other access control methods. I figure the safe option at this point is to log the value but crashing is also an option. What do you think? In addition, there is one place (rabbit_reader I think) where check_vhost_access is not caught. Hmm.

michaelklishin commented 4 years ago

I'd log the value and keep the catch clause.

lukebakken commented 4 years ago

OK that's what I have done, thanks.

lukebakken commented 4 years ago

@michaelklishin thank you for the reviews.