Commit graph

63 commits

Author SHA1 Message Date
Jan Holesovsky
f8ca17278f access_header: Pass the access_header around + unit test.
Change-Id: I5d6d93e289d8faceda59deae128e8124a0193d95
Reviewed-on: https://gerrit.libreoffice.org/41243
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: Jan Holesovsky <kendy@collabora.com>
2017-08-17 13:41:07 +02:00
Andras Timar
945d74c237 wsd: fix compilation with old OpenSSL that does not have PKCS5_PBKDF2_HMAC()
Change-Id: If48641f6cbcc4d4ded78ea5cc9c9f66063a2ac0a
Reviewed-on: https://gerrit.libreoffice.org/39779
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2017-07-31 19:40:37 +02:00
Miklos Vajna
c07efecdcf wsd: avoid string concatenation resulting in allocation of unnecessary temporary strings in FileServer
By using operator+= instead, which does not have this problem.

Change-Id: I6dd54cde7e430f2f1d549642dddd3ed1a0e9eefd
2017-07-05 11:22:06 +02:00
Miklos Vajna
3e6680209e wsd: remove unused using declarations in FileServer
Change-Id: Ia56e5af384791df036411fc4acd4b1c69afe30f4
2017-07-04 10:19:45 +02:00
Ashod Nakashian
c9b0dc0424 wsd: cleanup deflate data and free memory
With help from Valgrind to find and verify
these leaks. Also some minor cleanup to the
deflate logic.

Change-Id: I3bb3f1e01cef7025c45874ce52cfc922dfd19e21
Reviewed-on: https://gerrit.libreoffice.org/39465
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-07-03 05:43:22 +02:00
Pranav Kant
2c9966ed2f Bin unused header
Change-Id: I2067e793fe54e7c713b6d319c1f13b95a09923a3
2017-06-22 18:28:24 +05:30
Pranav Kant
2e42ae8c2f Enable HTTP key pinning when ssl termination is on too
Change-Id: Id2d7a34374236f50e28551ff9c57433d9153e2fd
2017-06-22 18:27:32 +05:30
Pranav Kant
5c7b9ce6e7 Consistency
Change-Id: I16889728d0062c058ea5831ff8892025e1719c3e
2017-06-12 16:09:10 +05:30
Pranav Kant
54ea436026 CSP - Add object-src: , this is required for printing documents
Change-Id: I4a759086f2b503dfa9df4000267d920984cfe422
2017-06-12 15:47:03 +05:30
Pranav Kant
2d0ec13249 CSP - allow WOPI host as image sources
This is needed to avoid CSP error when loading the avatar image URL from
the WOPI hosts.

Change-Id: I6bd8bd846f81bc799192e7fbc16b2d7ecc9f555e
2017-06-06 17:36:47 +05:30
Jan Holesovsky
9aecf428f6 Revert "wsd: enable option to remove About dialog elements"
The request was meant the other way around; let's just not present "About" in
the menu when there is no element with "about-dialog" id.

This reverts commit b9305d17ce.
2017-05-26 10:03:33 +02:00
Henry Castro
b9305d17ce wsd: enable option to remove About dialog elements
Change-Id: I33c351cbc7373255a22f44cb31e53f21a00869bf
2017-05-25 17:43:11 -04:00
Pranav Kant
7a4bc5b95a admin-console: Check the password against hashed value in config
The new password hash property is called secure_password in the config
file. `loolconfig` tool should be used to set the password hash in
appropriate format with desired salt length, password length, number of
iterations in PBKDF2.

To be backward compatible, plain-text password for admin-console in
config file is still accepted in case secure_password property is
missing from the config file.

Change-Id: If229999dac62856e368555c0242c4aa6f8061fba
2017-05-25 01:18:31 +05:30
Ashod Nakashian
873cbcbe91 wsd: logging corrections
Change-Id: I35c52494137ea174c218bf936bc2440634036e3e
Reviewed-on: https://gerrit.libreoffice.org/37889
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-22 07:03:47 +02:00
Pranav Kant
f47936a2da ENABLE_DEBUG has values either 0 or 1, otherwise its always defined.
Change-Id: I0253dc2d83c11888e79ddb991b065eb62bbbd805
2017-05-20 12:18:29 +05:30
Pranav Kant
4ef373ce5f wsd: Echo back port number in CSP too if found in Referer header
Otherwise, WOPI implementations that use non-standard ports get CSP
voilation errors in the browsers because Poco's URI::getHost() method
strips the port number from the host.

No harm in mentioning the port number always even if its a standard one,
so always use Poco::URI::getPort() to append the port to the frame
ancestor.

Change-Id: I9e7a7021b38f717e14af3d389e30f24ecaf6d122
2017-05-18 23:10:49 +05:30
Ashod Nakashian
d267b86bbd wsd: include version in http agent strings
And move the WOPI agent string to Common.hpp.

Change-Id: Ife679705bcd6914ddd45ad50446e690fb22dd317
Reviewed-on: https://gerrit.libreoffice.org/37607
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-05-15 05:10:06 +02:00
Ashod Nakashian
954a37a06c Configurable timeouts
Timeouts to dimming the doc in the browser
are now configurable from WSD and is relayed
to loleflet as expected.

Out of focus timeout is now 60 seconds.

Change-Id: I8452e30976f6a81b0c3bb3ba5774daa244c1640c
Reviewed-on: https://gerrit.libreoffice.org/37489
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
2017-05-11 08:01:30 +02:00
Jan Holesovsky
6d8aa453ab wsd: Handle a non-empty, but broken frame ancestor with 'deny' too.
Change-Id: I61b6e5c7cbe7f36ecd780865a613b7a240cf7b99
2017-05-10 14:46:21 +02:00
Pranav Kant
624fc5c5de wsd: Use HTTP Referer and then WOPISrc for frame ancestor
This is required in those setup where the document is not served from
the same host user is currently connected to. Use the Referer[sic]
header to set the frame ancestors and if they are absent, fallback to
WOPISrc value provided by the WOPI host.

Change-Id: Ia63a213d10aca2df56a2884e07322c1cd8056ff8
2017-05-08 15:32:43 +05:30
Michael Meeks
0088c14850 Allow env-var to affect serving from the FS only in debug mode.
Change-Id: I5e5d176295807af4de3e802ca02a0e1a1c17646e
2017-05-08 09:51:28 +01:00
Pranav Kant
052dec41be wsd: New environment variable to not serve from memory
Its quite time consuming having to restart loolwsd everytime you make
changes in loleaflet.

Change-Id: I5cc8c5af96e758309d21598c0f23fad9082130bd
2017-05-05 15:24:21 +05:30
Michael Meeks
cda55f3a21 Various cleanups & improvements to file-serving.
Use what we read at startup as the complete set of files to serve.
Trace log filenames as we read them.
Simplify and accelerate path related checks via the hash.
Kill leak with get_current_dir_name and use the correct path.
2017-04-27 15:02:16 +01:00
Aditya Dewan
be4ebb9b1f Migrated from deflate to gzip
Change-Id: I64aec9305fe74b6cdcfe15e2f67f9d38cfd6d99a
2017-04-27 15:02:16 +01:00
Pranav Kant
0c34857527 Bin superfluous object
Poco::DateTime is enough to create an object representing the current
date time, no need to create a timestamp first.

Change-Id: Ib95b43c1f7ae4993a6d9f7ec6da1234ac2bf59aa
2017-04-25 11:30:15 +05:30
Ashod Nakashian
8b3a2ed9d7 wsd: reduce included headers
Change-Id: I3107b18b2edae34a76e9f56a5cbd24836b1b57c0
Reviewed-on: https://gerrit.libreoffice.org/36872
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-04-24 06:52:02 +02:00
Henry Castro
1a580cc993 wsd: add mime type image/png
IE11 requires explicit content-type image/png

Change-Id: Ie0a886bc9b6af50be788456a93583176788c5315
2017-04-12 22:11:23 -04:00
Pranav Kant
699e8df9a7 Use CSP without WOPI host too
Fallback from b7eafb1e4a

Change-Id: I741a3f2320cfeec2250c10913871cf350861a39d
2017-04-12 19:58:19 +05:30
Pranav Kant
b7eafb1e4a Move CSP to response headers from meta tag in html
Some older browsers don't have meta tag support for CSP. Lets put all of
the CSP in response headers to be compatible with oldies.

Change-Id: I7f0d7c294e492b3c69ebea6fbd820d6558b9c3b3
2017-04-12 19:24:51 +05:30
Miklos Vajna
4dbdd72bc2 wsd: avoid std::string::compare() in FileServer
When we are just interested in equality. compare() is more meant for
sorting functions where negative/zero/positive return value is useful.

Change-Id: I11138a14dc08e23d33f3848aeb734d9f56f3e9f7
2017-04-12 13:46:09 +02:00
Pranav Kant
4d6b338bf0 security: Stricter Referrer-Policy: no-referrer
I don't think we should leak our address
(which mostly is behind a WOPI host and end-user
has no idea of what host LibreOffice Online is running at) in the
Referer header. Lets be more strict here and don't leak our address
at all.

Change-Id: Ibc30e9b64e2e06e2e8d541c5f089320ecb11412b
2017-04-11 00:02:00 +05:30
Pranav Kant
1437a060ec security: Implement HTTP Public key pinning
Though this guard the user against MITM attacks, but enabling this also
has the potential to brick your websites. So, do not use it/enable it
without understanding what it actually is.

See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning

Though this should work, but I have not been able to test it because of
Firefox and Chrome's limitation/feature that key validation is not done
when certificate chain terminates at a user-defined trust anchor and I
couldn't find any way to temporarily enable the HPKP key validation for
such CA chains.

Change-Id: I64d4ff82b04c59642fa7b8bac2f8788a03950b28
Reviewed-on: https://gerrit.libreoffice.org/36357
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
2017-04-10 14:46:24 +02:00
Pranav Kant
74020e0f1f Revert "wsd: Fileserver cleanup"
This reverts commit de2bc17c04af088d9c7e18a97216b174494e1a9c.

Lets not introduce any cleanup commits while we are near a release, will
apply it again after the release. The cleanup is supposed to not handle
the custom file server root correctly, so don't forget to test it with
a custom file server root before re-reverting.

It changes the path where loleaflet.html is searched for from
/usr/share/loolwsd/loleaflet/... to /usr/share/loleaflet/...
and doesn't find it there.

Change-Id: I23940e9a3e06721f0a8b7493a526f42d2072cfa4
2017-04-10 15:26:05 +05:30
Pranav Kant
a0d7c33877 security: X-Frame-Options: Deny framing if no wopi host
Change-Id: I6936f8a11e3e076e111e0883305f47064e032983
2017-04-10 15:26:00 +05:30
Pranav Kant
1ca873d57e security: X-XSS-Protection header
Change-Id: I050cba3ad8aeedaefa773d78254a3a37a7ddef30
2017-04-09 23:32:06 +05:30
Pranav Kant
61b7112aa7 security: X-Content-Type-Options: nosniff
Don't think it is necessary/useful to have this header at other places.
This is the most important and perhaps the only where presence of this
header is required and seems sensible to prevent potential attacks.

Change-Id: Iad318e4b83264ac83620b86a40a49e7384e4015e
2017-04-09 23:32:06 +05:30
Pranav Kant
df8ac5f33e wsd: Only set these headers if its WOPI
Change-Id: I1ccedc9828a724b55f8642aaa2b934c37f49a4dd
2017-04-09 23:32:06 +05:30
Pranav Kant
1a1a3ebb3c wsd: Fileserver cleanup
Remove unnecessary checks

Rename preprocessFile -> preprocessAndSendLoleafletHtml and
Rename isAdminLoggedIn -> tryAdminLogin
so that their name matches the actual reality of what these
function really does.

Change-Id: I549eae31f8ab0a320bb3ff8ecd17a282b8f91e1a
2017-04-07 13:46:04 +05:30
Pranav Kant
1614f8d417 security: Mention X-Frame-Options too for ie/edge
ie/edge ignores frame-ancestor directive of CSP (yet). Mention X-Frame-Options
for them. Similary, X-Frame-Options allow-from attribute is not
supported by Chrome:
(see https://bugs.chromium.org/p/chromium/issues/detail?id=511521)
In that case, we already have frame-ancestor CSP directive for it.

Change-Id: Ide00c4db88c438de5e9c679360b3da6f4eb4a1be
2017-04-07 13:46:04 +05:30
Pranav Kant
ffc5d516b4 security: CSP: Add frame-ancestor directive
Block embedding LibreOffice Online is frames of different origin.

Change-Id: If3e04a0704e42853dc757b4be1f30fc22b8b33e4
2017-04-07 13:46:04 +05:30
dewana-dewan
4322045667 tdf#106579 - serving gzipped file content
Change-Id: I320b22babf1bf65a0f1d4b1809a6ffb1f5ec8344
2017-03-30 12:09:12 +01:00
Michael Meeks
e7ebe0fdaa remove obsolete Poco headers, and Poco SSL pieces. 2017-03-16 18:03:23 +00:00
Michael Meeks
97cb6597c8 Admin: don't set 'secure' on auth cookie for http.
Also tweak paths to accomodate bundlification, apparently un-necessary
in secure cookie mode, interestingly.
2017-03-16 16:44:27 +00:00
Michael Meeks
f392d9e6f0 Move http serving into socket impl.
Avoid caching headers with parameter, and add Date: parameter.
2017-03-15 18:21:59 +00:00
Ashod Nakashian
8b9623010a wsd: sendHttpResponse -> send
Change-Id: I7c94f6d4cd1054ea86585bfcd4079140471f3518
Reviewed-on: https://gerrit.libreoffice.org/35157
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2017-03-14 04:30:55 +00:00
Michael Meeks
fad3a046ae AdminConsole - get credentials sorted, and serve the HTML pieces. 2017-03-13 21:48:19 +00:00
Michael Meeks
71a1e188a7 Handle If-None-Match / ETag (hopefully) - hard to test ... 2017-03-11 22:28:59 +00:00
Michael Meeks
173ca5e3d6 Quote ETag. 2017-03-10 16:42:48 +00:00
Michael Meeks
3b370022c0 Improve state dumping. 2017-03-10 15:37:09 +00:00
Ashod Nakashian
b8af470918 nb: serve files synchronously
As there isn't support (yet) to send files
asynchronously, when the socket native buffer
is small, asynchronous writes naturally return
EWOULDBLOCK. As a temp solution, we send files
synchronously, so there is no need to poll.

This should be replaced witha file-server
polling/serving thread that is dedicated to
sending files only (which closes the connection
when done).

Change-Id: I062fea44bfe54ab8d147b745da97bd499bf00657
2017-03-10 10:47:44 +01:00