diff options
author | Ed Tanous <edtanous@google.com> | 2023-03-28 00:43:19 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2023-06-08 19:40:08 +0300 |
commit | c51a58ee9231e48bb25ede75307591758f911395 (patch) | |
tree | d0c17dfd7aff3cc453fee667ff999fa0f61908ee /include/forward_unauthorized.hpp | |
parent | f9c794fbf2053c664902efa5d9ef638ef08acb38 (diff) | |
download | bmcweb-c51a58ee9231e48bb25ede75307591758f911395.tar.xz |
Remove urlEncode
All new uses should be using boost::urls::url now. This was the last
usage.
Tested: Logged into webui, and observed the correct URL behavior.
In browser window /foobar
Forwarded to /?next=/foobar#/login
Which is correct.
Note, this is different behavior slightly than before. It was found
that the URI precedence goes query string THEN fragment, rather than the
other way around that we had it. This was flagged when moving over to
boost url structures.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ifb354537d71a43c531d7d380dd889cf646731e39
Diffstat (limited to 'include/forward_unauthorized.hpp')
-rw-r--r-- | include/forward_unauthorized.hpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/include/forward_unauthorized.hpp b/include/forward_unauthorized.hpp index 4ec770f598..9ba2b1cef9 100644 --- a/include/forward_unauthorized.hpp +++ b/include/forward_unauthorized.hpp @@ -3,6 +3,9 @@ #include "http_response.hpp" #include "http_utility.hpp" +#include <boost/url/format.hpp> +#include <boost/url/url.hpp> + namespace forward_unauthorized { @@ -21,9 +24,11 @@ inline void sendUnauthorized(std::string_view url, // If we have a webui installed, redirect to that login page if (hasWebuiRoute) { + boost::urls::url forward = boost::urls::format("/?next={}#/login", + url); res.result(boost::beast::http::status::temporary_redirect); res.addHeader(boost::beast::http::field::location, - "/#/login?next=" + http_helpers::urlEncode(url)); + forward.buffer()); return; } // If we don't have a webui installed, just return an unauthorized |