[Libreoffice-commits] online.git: loolwsd/Common.hpp loolwsd/FileServer.hpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Sat Apr 16 17:28:01 UTC 2016


 loolwsd/Common.hpp     |    1 -
 loolwsd/FileServer.hpp |   15 +++++++--------
 2 files changed, 7 insertions(+), 9 deletions(-)

New commits:
commit c2560725db90e8d5779cfe8fd9e774691c92ad6d
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sat Apr 16 08:02:15 2016 -0400

    loolwsd: admin uses config for ssl key
    
    Change-Id: I38b0f59c158698a6eb89d4b671001e1d8cb61673
    Reviewed-on: https://gerrit.libreoffice.org/24129
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/Common.hpp b/loolwsd/Common.hpp
index 2d9db68..43a67e9 100644
--- a/loolwsd/Common.hpp
+++ b/loolwsd/Common.hpp
@@ -38,7 +38,6 @@ constexpr auto FIFO_LOOLWSD = "loolwsdfifo";
 constexpr auto FIFO_PATH = "pipe";
 constexpr auto JAILED_DOCUMENT_ROOT = "/user/docs/";
 constexpr auto NEW_CHILD_URI = "/loolws/newchild?";
-constexpr auto SSL_KEY_FILE = "key.pem";
 
 // The client port number, both loolwsd and the kits have this.
 extern int ClientPortNumber;
diff --git a/loolwsd/FileServer.hpp b/loolwsd/FileServer.hpp
index 2941c35..a749f06 100644
--- a/loolwsd/FileServer.hpp
+++ b/loolwsd/FileServer.hpp
@@ -57,6 +57,9 @@ public:
     /// Evaluate if the cookie exists, and if not, ask for the credentials.
     static bool isAdminLoggedIn(HTTPServerRequest& request, HTTPServerResponse& response)
     {
+        const auto& config = Application::instance().config();
+        const auto sslKeyPath = config.getString("ssl.key_file_path", "");
+
         if (request.find("Cookie") != request.end())
         {
             // FIXME: Handle other cookie params like '; httponly; secure'
@@ -66,9 +69,7 @@ public:
 
             const std::string jwtToken = request["Cookie"].substr(pos + 1);
             Log::info("Verifying JWT token: " + jwtToken);
-            // TODO: Read key from configuration file
-            const std::string keyPath = "/etc/loolwsd/" + std::string(SSL_KEY_FILE);
-            JWTAuth authAgent(keyPath, "admin", "admin", "admin");
+            JWTAuth authAgent(sslKeyPath, "admin", "admin", "admin");
             if (authAgent.verify(jwtToken))
             {
                 Log::trace("JWT token is valid");
@@ -78,8 +79,8 @@ public:
             Log::info("Invalid JWT token, let the administrator re-login");
         }
 
-        const auto user = Application::instance().config().getString("admin_console_username", "");
-        const auto pass = Application::instance().config().getString("admin_console_password", "");
+        const auto user = config.getString("admin_console_username", "");
+        const auto pass = config.getString("admin_console_password", "");
         if (user.empty() || pass.empty())
         {
             Log::error("Admin Console credentials missing. Denying access until set.");
@@ -92,9 +93,7 @@ public:
         {
             const std::string htmlMimeType = "text/html";
             // generate and set the cookie
-            // TODO: Read key from configuration file
-            const std::string keyPath = "/etc/loolwsd/" + std::string(SSL_KEY_FILE);
-            JWTAuth authAgent(keyPath, "admin", "admin", "admin");
+            JWTAuth authAgent(sslKeyPath, "admin", "admin", "admin");
             const std::string jwtToken = authAgent.getAccessToken();
             Poco::Net::HTTPCookie cookie("jwt", jwtToken);
             cookie.setPath("/adminws/");


More information about the Libreoffice-commits mailing list