diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2019-08-26 21:16:54 -0400 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2019-10-28 10:45:14 +0100 |
commit | 8c4edb5087ac5f225b992d795c5ba33c4a5b5f38 (patch) | |
tree | a31d52f80ef17440c7ae5ba3a1ccbdc3f3dcb262 /wsd/FileServer.cpp | |
parent | Added reuse cookie option for wopi client (diff) | |
download | online-8c4edb5087ac5f225b992d795c5ba33c4a5b5f38.tar.gz online-8c4edb5087ac5f225b992d795c5ba33c4a5b5f38.zip |
Reuse cookies from the browser
Reviewed-on: https://gerrit.libreoffice.org/78195
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
(cherry picked from commit 8deecf4ea6966c059458bdc71e365be426238e09)
Change-Id: I96bbdd3e71bc9d0ecfddea7debc0ebcc303a49ae
Reviewed-on: https://gerrit.libreoffice.org/81558
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'wsd/FileServer.cpp')
-rw-r--r-- | wsd/FileServer.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp index f8b650d295..0085bee285 100644 --- a/wsd/FileServer.cpp +++ b/wsd/FileServer.cpp @@ -678,6 +678,20 @@ void FileServerRequestHandler::preprocessFile(const HTTPRequest& request, Poco:: const std::string idleTimeoutSecs= config.getString("per_view.idle_timeout_secs", "900"); Poco::replaceInPlace(preprocess, std::string("%IDLE_TIMEOUT_SECS%"), idleTimeoutSecs); + // Capture cookies so we can optionally reuse them for the storage requests. + { + NameValueCollection cookies; + request.getCookies(cookies); + std::ostringstream cookieTokens; + for (auto it = cookies.begin(); it != cookies.end(); it++) + cookieTokens << (*it).first << "=" << (*it).second << (std::next(it) != cookies.end() ? ":" : ""); + + const std::string cookiesString = cookieTokens.str(); + if (!cookiesString.empty()) + LOG_DBG("Captured cookies: " << cookiesString); + Poco::replaceInPlace(preprocess, std::string("%REUSE_COOKIES%"), cookiesString); + } + const std::string mimeType = "text/html"; std::ostringstream oss; @@ -693,20 +707,6 @@ void FileServerRequestHandler::preprocessFile(const HTTPRequest& request, Poco:: "X-XSS-Protection: 1; mode=block\r\n" "Referrer-Policy: no-referrer\r\n"; - const std::string reuseCookie = form.get("reuse_cookies_for_storage", ""); - if (reuseCookie == "true") - { - NameValueCollection cookies; - request.getCookies(cookies); - std::ostringstream cookieTokens; - - for (auto it = cookies.begin(); it != cookies.end(); it++) - { - cookieTokens << (*it).first << "=" << (*it).second << (std::next(it) != cookies.end() ? ":" : ""); - } - setenv("LOOL_REUSE_STORAGE_COOKIE", cookieTokens.str().c_str(), 1); - } - // Document signing: if endpoint URL is configured, whitelist that for // iframe purposes. std::ostringstream cspOss; |