From a9dabd661bea5cb0a3aa9098216d44d5c4265975 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Wed, 17 Jan 2018 22:04:05 -0800 Subject: [PATCH] ircd: Propagate better error back to user here for now. --- ircd/resource.cc | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/ircd/resource.cc b/ircd/resource.cc index fbc7a17fb..1c2269100 100644 --- a/ircd/resource.cc +++ b/ircd/resource.cc @@ -173,6 +173,7 @@ void ircd::verify_origin(client &client, resource::method &method, resource::request &request) +try { const auto &authorization { @@ -189,11 +190,27 @@ ircd::verify_origin(client &client, m::verify_x_matrix_authorization(authorization, method.name, uri, request.content) }; - if(!verified) - throw m::error - { - http::UNAUTHORIZED, "M_INVALID_SIGNATURE", "The X-Matrix Authorization is invalid." - }; + if(verified) + return; + + throw m::error + { + http::UNAUTHORIZED, "M_INVALID_SIGNATURE", + "The X-Matrix Authorization is invalid." + }; +} +catch(const m::error &) +{ + throw; +} +catch(const std::exception &e) +{ + throw m::error + { + http::UNAUTHORIZED, "M_INTERNAL_ERROR", + "An error has prevented authorization: %s", + e.what() + }; } void