Commit graph

3753 commits

Author SHA1 Message Date
John McLear
e051f2f2f7 lint: scroll.js 2020-12-26 20:43:10 +00:00
webzwo0i
b760e699c6 remove explicitly setting process.env.DEBUG 2020-12-24 08:46:25 +00:00
Richard Hansen
9a15af78b6 Regenerate src/package-lock.json with npm v6.14.9
This reverts the file back to lockfileVersion 1, which is used by the
LTS version of npm.
2020-12-23 16:58:30 -05:00
John McLear
d9262fccbd bump version 2020-12-23 16:18:28 -05:00
John McLear
1a845773ee css: loading position box 2020-12-23 16:18:28 -05:00
Richard Hansen
f31232dd20 socket.io: Disconnect clients when closing HTTP server 2020-12-23 16:18:28 -05:00
Richard Hansen
9f7d42185d socket.io: Reconnect if the server disconnects
This will make the pages gracefully handle HTTP server restart events,
which happen whenever a plugin is installed or uninstalled via the
`/admin/plugins` page.
2020-12-23 16:18:28 -05:00
Richard Hansen
303964c51e socket.io: Factor out client connection logic 2020-12-23 16:18:28 -05:00
Richard Hansen
7eb0f996c3 socket.io: Delete ignored resource option
I couldn't find any reference to a `resource` option in either the
socket.io-client documentation or its source code.
2020-12-23 16:18:28 -05:00
Richard Hansen
7949219179 Reformat src/ep.json 2020-12-23 16:18:28 -05:00
Richard Hansen
8c1afc3399 express: New expressCloseServer hook
This will be used by a future commit to close all socket.io
connections during server restart.
2020-12-23 16:18:28 -05:00
Richard Hansen
3e8c3e5789 express: Factor out common server shutdown logic
Also log when the HTTP server is about to be closed and when it is
done closing.
2020-12-23 16:18:28 -05:00
Richard Hansen
ff19181cd1 lint: Fix some straightforward ESLint errors 2020-12-23 16:18:28 -05:00
translatewiki.net
ac086c7925 Localisation updates from https://translatewiki.net. 2020-12-23 16:18:28 -05:00
webzwo0i
790ba72a9e change scroll-behavior to auto
timeslider follow test: ensure there are so much lines in the pad view
below the changed line, so that the changed line will be the first
visible line
2020-12-23 16:18:28 -05:00
John McLear
996a2d86dd lint: chat (#4573)
Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2020-12-23 16:18:28 -05:00
John McLear
8bf463fb00 lint: broadcast_revisions (#4571)
Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2020-12-23 16:17:59 -05:00
John McLear
4aef15cb11
lint: collab-client (#4574)
* lint: collab-client

* Undo incorrect lint fixes

These will be re-fixed in a future commit.

* Properly fix guard-for-in error

* Properly fix prefer-rest-params errors

* Move some code back to where it was

Moving the code makes it hard to review the diff.

* Delete DISCONNECT_REASON case

Someone reading the code won't understand what "used to handle
appLevelDisconnectReason" means until they dig through the Git
history. Given the server never sends messages of type
DISCONNECT_REASON anyway, just delete the case.

* Refine lint fixes

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2020-12-21 20:19:00 +00:00
Hossein Marzban
170a230c3a
Lint: timeslider (#4580)
Squashed changes from rhansen@rhansen.org:
  * Move code back to where it was. (It's easier to review changes
    when the code isn't moved. This causes some no-use-before-define
    warnings to reappear, but those are just warnings.)
  * Move eslint-disable comment to same line
  * Use `window.clientvars` to resolve no-global-assign
  * Undo changes that aren't about fixing lint errors
2020-12-20 18:24:17 -05:00
John McLear
bca60c8b17 lazydeveloper: remove console log 2020-12-20 10:56:19 +00:00
John McLear
e18b9d1844 timeslider/bugfix: timeslider wasn't updating when new pad contents was created - #4595 2020-12-20 10:45:16 +00:00
John McLear
0362d3b05d
lint: pad prefix files (#4577)
* lint: pad_connectionstatus

* lint: pad_utils

* lint: pad_userlist.js -- still WIP

* shift underscore not to be in require but to be used from window

* lint: pad_modals

* pad_impexp.js

* lint: more errors done

* lint: auto reconn

* lint: pad_editor

* lint: finish auto reconn

* lint: imp exp rework

* lint: import

* lint: pad.js nearly done but pizza here...

* lint: clientVars global query

* put clientVars in window

* Revert incorrect lint fixes

* Properly fix guard-for-in lint errors

* Properly fix no-unused-vars error regarding `gritter`

* Refine lint fixes

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2020-12-20 07:15:58 +00:00
Hossein Marzban
34ee77993f
Lint: pluginfw tsort.js (#4576)
* lint: pluginfw tsort.js

* Don't comment out the `console.log()` call

Disabling the log message is out of scope for the pull request.

* Put const and let on separate lines

* Convert `tsort` from function to arrow function

ESLint doesn't complain about this due to a bug in
prefer-arrow/prefer-arrow-functions rule:
https://github.com/TristonJ/eslint-plugin-prefer-arrow/issues/24

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2020-12-20 06:18:49 +00:00
webzwo0i
a637920e55
add list-style:none for ul.indents in exported HTML (#4586)
* add list-style:none for ul.indents in exported HTML

* use list-style-type not list-style
2020-12-20 06:00:18 +00:00
Richard Hansen
b82bf5c726 Drop support for Internet Explorer 2020-12-19 19:13:31 +00:00
webzwo0i
c5cf7ab144
tests: Ignore head tag on import / improved contentcollector tests
* fix accidental write to global variable
properly show pending tests
log test name in suite
better log output for received/expected strings

* cc tests: enable second nestedOL test

* ignore the head tag on import
2020-12-18 09:37:37 +00:00
Richard Hansen
d9b7aa489d pad import/export: Delete dead functions 2020-12-18 09:29:28 +00:00
Richard Hansen
7e50fc2ab5 Delete dead SERVER_MESSAGE and guest handling code
None of this code seems to be reachable. Hopefully no plugins expect
it to exist.
2020-12-18 09:29:28 +00:00
Richard Hansen
794dfb1863 lint: Bump eslint-config-etherpad and install its new deps 2020-12-17 22:18:29 +00:00
translatewiki.net
c9db9500e5 Localisation updates from https://translatewiki.net. 2020-12-17 15:13:17 +01:00
Richard Hansen
f54dcbc766 lint: Re-run eslint --fix 2020-12-16 22:09:48 +00:00
Richard Hansen
fc234d0088 lint: Bump eslint and eslint-config-etherpad versions 2020-12-16 22:09:48 +00:00
Richard Hansen
af7cd13787 pad: Add a hook for the permission denied block
This makes it possible for the ep_readonly_guest plugin to add a login
button.
2020-12-16 19:39:52 +00:00
Richard Hansen
92b295193f css: Apply font formatting to the text, not the high-level div
This makes it possible for plugins to add new items without them
rendering centered, at a ridiculous size, or at an awkward location.
2020-12-16 19:39:52 +00:00
Richard Hansen
27dab35827 css: Delete absolute line-height
Having an absolute `line-height` causes problems when something sets
`font-size` without also setting `line-height`.
2020-12-16 19:39:52 +00:00
John McLear
92e36b82b5
linting: pad_editbar.js 2020-12-16 12:12:25 +00:00
Hossein Marzban
6f309ac20a
lint: pluginfw/client_plugins (#4572) 2020-12-15 21:40:41 -05:00
Richard Hansen
a4e2ea7a8c Add missing dependency on mime-types
mime-types is used by `src/node/utils/Minify.js` since commit
2c944eba34.
2020-12-14 20:31:35 +00:00
Richard Hansen
edf647044c Update package-lock.json and src/package-lock.json 2020-12-14 20:31:35 +00:00
translatewiki.net
ef8a581acd Localisation updates from https://translatewiki.net. 2020-12-14 15:05:13 +01:00
Michael Murtaugh
66e3f02ed2
editor/bugfix: missing await in createClearStartAtext (#4561)
Missing await in call to this._pad.getInternalRevisionAText(rev). Function returns a promise. This bug breaks the createDiffHTML API call (how I discovered it).
2020-12-14 07:04:14 +00:00
Richard Hansen
a44debdcfe Add ' and * to acceptable URL characters
These characters are in the RFC3986 reserved set.

These characters are added to the set of characters that cannot be the
last character of a URL to avoid mislinkification.
2020-12-14 07:03:17 +00:00
Richard Hansen
7d23278ed0 Exclude ?, !, and ) from last character of URL
Now the final character in each of these example strings is no longer
considered part of the URL:
  * Have you seen http://example.com?
  * Look at http://example.com!
  * (see http://example.com)
2020-12-14 07:03:17 +00:00
Richard Hansen
7e8de5540f Factor out common URL regular expression code
This also eliminates the differences between the regular expressions.
2020-12-14 07:03:17 +00:00
Richard Hansen
ca01856f94 lint: Fix some straightforward ESLint errors 2020-12-14 07:03:17 +00:00
Richard Hansen
e66e8a4eb2 pad: Fix wrong variable name in global exception handler
This fixes a bug introduced in commit
c845d985e0.
2020-12-10 22:25:58 +00:00
webzwo0i
d25010d5d7
pluginfw: explicitly install the latest version of a plugin, fix for #4536 (#4543) 2020-12-05 14:08:02 +00:00
webzwo0i
0c7df88f8a
add rehype-minify-whitespace to package.json (#4544) 2020-12-05 12:16:25 +00:00
John McLear
ef2de59587
editor: use rehype-minify-whitespace
use rehype-minify-whitespace

Co-authored-by: webzwo0i <webzwo0i@c3d2.de>
2020-12-05 08:14:09 +00:00
John McLear
de5e071294 path issue 2020-12-05 07:51:17 +00:00
John McLear
159b6a4ba1 database: bump ueberdb to 056 to ensure correct engine is used 2020-12-05 07:51:17 +00:00
zonky2
0f1d5e068a
css: Make color button from elipsoid to circle (#4535)
Make color button from elipsoid to circle by own user
https://easycaptures.com/fs/uploaded/1536/3084360130.png
2020-12-05 07:32:15 +00:00
Richard Hansen
aa41b0920c admin/plugins: Don't keep adding more Update buttons 2020-11-27 16:59:24 +00:00
Richard Hansen
6a00d7f8d6 admin/plugins: Use jQuery to build the Update button 2020-11-27 16:59:24 +00:00
Richard Hansen
2ddc45bf07 admin/plugins: Simplify jQuery search for plugin actions 2020-11-27 16:59:24 +00:00
Richard Hansen
973644c7dd lint: Fix ESLint errors in /admin/plugins code 2020-11-27 16:59:24 +00:00
Richard Hansen
6a5f905090 admin: Delete unused search_results
This silences some ESLint camelcase warnings.
2020-11-27 16:59:24 +00:00
Richard Hansen
2fdac836d0 lint: Bump eslint-config-etherpad to 1.0.13
Also bump eslint to 7.14.0.
2020-11-27 06:25:43 +00:00
Richard Hansen
750c7cb1cf pad: Delete unused ip and userAgent client vars 2020-11-26 15:00:46 +00:00
Richard Hansen
98066184b2 PadMessageHandler: Don't fill in default name or color
It should be the client's responsibility to handle null name or color.
In the case of author names, passing null to the client allows users
to fill in the names of other users (via a suggestUserName
CLIENT_MESSAGE).
2020-11-26 15:00:46 +00:00
Richard Hansen
ef7ae15722 PadMessageHandler: Don't send USER_NEWINFO about unknown authors
When a new client opens a socket.io connection and sends a
CLIENT_READY message, Etherpad sends the new client a bunch of
USER_NEWINFO messages, one per other user already connected to the
pad. When iterating over the other users, filter out those without an
author ID or missing from the global authors database.
2020-11-26 15:00:46 +00:00
Richard Hansen
53bc80e381 pad userlist: Use jQuery to create rows
This makes the code easier to read and maintain, and it reduces the
likelihood of introducing an XSS vulnerability.
2020-11-26 15:00:46 +00:00
Ilmar Türk
ba7d80fa57
Update dropdowns on language change (#4519) 2020-11-25 21:39:21 +00:00
Richard Hansen
b13004b25a
Minify: Accept single quotes in ace.js's $$INCLUDE_*(...) lines (#4513)
This fixes a bug introduced in commit
8e5fd19db2.
2020-11-25 03:40:02 +01:00
Richard Hansen
e247c716c2 editor: Add argument to suppress SonarCloud error
This also makes it easier for devs to understand the expected function
signature.
2020-11-24 20:06:12 +00:00
Richard Hansen
d24306ea6a editor: Delete unused isTimeUp argument
This fixes a SonarCloud error.
2020-11-24 20:06:12 +00:00
Richard Hansen
ed7ba64635 editor: Delete unused optModFunc argument 2020-11-24 20:06:12 +00:00
Richard Hansen
d0114d4ac2 editor: Delete commented-out code 2020-11-24 20:06:12 +00:00
Richard Hansen
bb722763d0 editor: Delete dead code
This silences some SonarCloud errors.
2020-11-24 20:06:12 +00:00
Richard Hansen
8e5fd19db2 lint: Run eslint --fix on src/ 2020-11-24 20:06:12 +00:00
Richard Hansen
0625739cb8 lint: Declare variables above their first use
This makes it possible to convert from `var` to `let` without getting
ReferenceErrors.
2020-11-24 20:06:12 +00:00
Richard Hansen
8ea1a1b90a lint: Prevent comments from being interpreted as JSDoc comments 2020-11-24 20:06:12 +00:00
Richard Hansen
7df3ded66f lint: Put opening brace on same line as function
Normally I would let `eslint --fix` do this for me, but there's a bug
that causes:

    const x = function ()
    {
      // ...
    };

to become:

    const x = ()
    => {
      // ...
    };

which ESLint thinks is a syntax error. (It probably is; I don't know
enough about the automatic semicolon insertion rules to be confident.)
2020-11-24 20:06:12 +00:00
Richard Hansen
cc988bd67b lint: Convert CR+LF line endings to LF 2020-11-24 20:06:12 +00:00
Richard Hansen
a78d6605b7 lint: Configure ESLint 2020-11-24 20:06:12 +00:00
Richard Hansen
6665c4693f Clear hang timeout timer when LibreOffice exits
This prevents `npm test` from freezing for two minutes after the tests
complete.

Also switch to an arrow function for the `setTimeout` callback.
2020-11-24 10:04:14 +00:00
webzwo0i
f2febcfc7e
minify: Fix gzip not triggered for packages (#4491)
* caching_middleware: fix gzip compression not triggered

* packages: If a client sets `Accept-Encoding: gzip`, the responseCache will
include `Content-Encoding: gzip` in all future responses, even
if a subsequent request does not set `Accept-Encoding` or another client
requests the file without setting `Accept-Encoding`.
Fix that.

* caching_middleware: use `test` instead of `match`

* add tests

* make code easier to understand

* make the regex more clear
2020-11-22 09:23:33 +00:00
John McLear
776eda2d4e
import/export: Kill soffice spawned process after 120 seconds (#4499)
Due to libreoffice being buggy / hanging on certain pdf imports (even in 7.0.3) we should just kill it so it doesn't consume CPU indefinitely.
2020-11-20 18:33:31 -05:00
Richard Hansen
867fdbd3f9 webaccess: Asyncify checkAccess 2020-11-19 09:05:38 +00:00
Richard Hansen
a803f570e0 webaccess: Don't export checkAccess
Nobody uses it outside of this module.
2020-11-19 09:05:38 +00:00
Richard Hansen
5d585a12d6 webaccess: Fix some ESLint errors 2020-11-19 09:05:38 +00:00
Richard Hansen
4587c0fb4d webaccess: Use a non-capturing regex group 2020-11-19 09:05:38 +00:00
Richard Hansen
a05e8198c9
bugfix: Fix bad paren placement in /javascript handler (#4496)
* Fix bad paren placement in `/javascript` handler

This fixes a bug introduced in commit
ed5a635f4c.

* add regression test for #4495

* Move `/javascript` test to `specialpages.js`

Co-authored-by: webzwo0i <webzwo0i@c3d2.de>
2020-11-19 08:19:13 +00:00
Richard Hansen
07bcbbd404 pad: Include the stack in the data sent to /jserror 2020-11-17 08:02:27 +00:00
Richard Hansen
c845d985e0 pad: Pop up an error message on unhandled Promise rejection 2020-11-17 08:02:27 +00:00
Richard Hansen
93c335b3b8 pad: Use a relative URL to simplify
Also avoid creating an unnecessary variable.
2020-11-17 08:02:27 +00:00
translatewiki.net
41d02db023 Localisation updates from https://translatewiki.net. 2020-11-16 15:15:14 +01:00
webzwo0i
1d8e8d3484 terser was not called because mime type did not match 2020-11-15 19:46:48 +00:00
Richard Hansen
cedd27e4fe plugins: Default the module name to the plugin name 2020-11-13 20:30:27 +00:00
Richard Hansen
afb025030c plugins: Use a log4js logger for npm messages 2020-11-13 20:30:27 +00:00
Richard Hansen
8a918fbc46 plugins: asyncify more functions 2020-11-13 20:30:27 +00:00
Richard Hansen
9f575ebc84 plugins: Delete unused ensure function 2020-11-13 20:30:27 +00:00
Richard Hansen
ac5614dadd plugins: Don't export callInit
It's unused outside of this module.

Also use an arrow function.
2020-11-13 20:30:27 +00:00
Richard Hansen
ba4794cf8a plugins: Call require('./hooks') at top level 2020-11-13 20:30:27 +00:00
Richard Hansen
14a9479e69 plugins: Use functions from fs.promises 2020-11-13 20:30:27 +00:00
Richard Hansen
d624aa936e plugins: Fix plugin name in error messages 2020-11-13 20:30:27 +00:00
Richard Hansen
6a8563eeab import/export: Simplify exportEtherpadAdditionalContent processing
Also:
  * Improve parallelization
  * Refine the documentation
2020-11-10 23:02:43 +00:00
Richard Hansen
8c55a38582 HTML export: Add missing )
This bug was introduced in 68a91f5e24.
2020-11-10 02:51:55 -05:00
Richard Hansen
68a91f5e24 HTML export: Move padId to context object property 2020-11-10 07:13:26 +00:00
John McLear
881d8b8d95
pluginfw: Hook to include additional body in HTML exports (#4469)
* hook, needs docs

* docs
2020-11-06 13:48:59 +00:00
John McLear
3fa58efede
pluginfw: Export .etherpad hooks (#4466)
* export support

* proper prefix

* just a basic example, needs working on still

* docs

* comments shouldnt be hard coded
2020-11-06 13:48:25 +00:00
ilmar
d5c5ca224b Fix missing arg handling in html10n.js 2020-11-05 10:38:22 +00:00
Richard Hansen
405e3e3e19 Settings: Don't filter out users based on password or hash
Some authentication plugins use the users defined in the `users`
object but ignore the `password` and `hash` properties.

This change deletes all of the filtering logic, including the logic
that filters out users that have both `password` and `hash` properties
defined. I could have kept that check, but decided to remove it
because:
  * There's no harm in defining both `hash` and `password`.
  * Allowing both makes it easier to transition from one scheme to
    another.
  * It's fewer lines of code to maintain.
2020-11-04 18:06:08 +00:00
Richard Hansen
6408d2313c webaccess: Be extra paranoid about nullish password
If `settings.json` contains a user without a `password` property then
nobody should be able to log in as that user using the built-in HTTP
basic authentication. This is true both with and without this change,
but before this change it wasn't immediately obvious that a malicious
user couldn't use an empty or null password to log in as such a user.
This commit adds an explicit nullish check and some unit tests to
ensure that an empty or null password will not work if the `password`
property is null or undefined.
2020-11-04 18:06:08 +00:00
Richard Hansen
98de2b0899 Use contentEditable for all browsers
This makes it possible to disable `contentEditable` for certain
elements in some circumstances (e.g., on links so that users can click
on them normally).
2020-11-03 19:02:01 +00:00
Richard Hansen
5e2a27a182 Replace setClassPresence(x, ...) with x.classList.toggle(...) 2020-11-03 19:02:01 +00:00
Richard Hansen
4594608c04 Delete commented-out code 2020-11-03 19:02:01 +00:00
Richard Hansen
91268e14b7 PadMessageHandler: Rename client to socket
The `client` variable is actually a socket.io Socket object. Rename it
to reduce confusion.
2020-11-02 20:39:08 +00:00
Richard Hansen
ed5a635f4c Add req to EJS render args when possible
This makes it possible for EJS templates and `eejsBlock_*` hook
functions to access the user's express-session state.
2020-11-02 16:05:01 +00:00
translatewiki.net
127923eb54 Localisation updates from https://translatewiki.net. 2020-11-02 12:40:50 +01:00
Gabriel Medeiros Coelho
ce77c48475 remove unnecessary conditional
if animationState evaluates to -1 or 0, it would end up in a conditional that assign its value to itself. Since this is redundant, it is better to remove this conditional, to avoid an extra check
2020-11-01 01:41:09 -05:00
webzwo0i
66a3647579 remove broken async inclusion in tar.json 2020-10-27 20:33:09 +00:00
Richard Hansen
2f65987ba2 webaccess: Remove user's password from session info
This prevents the password from being logged or stored in the
database.
2020-10-27 20:30:01 +00:00
translatewiki.net
50c22f0ae4 Localisation updates from https://translatewiki.net. 2020-10-26 15:56:46 +01:00
Viljami Kuosmanen
c502ca3259 Use isHttpError utility provided by http-errors
This new utility method was introduced in http-errors v1.8.0. Let's use
that instead of instanceof. This also upgrades the http-errors dependency
2020-10-25 10:45:58 +00:00
Viljami Kuosmanen
aef4cce0c9 Use correct constructor for 404,501 error handlers
Fixes error message mentioned in #4378.
2020-10-25 10:45:58 +00:00
Sebastian Castro
5a1110d0d6 Display outline when toolbar button focused 2020-10-25 10:34:51 +00:00
Richard Hansen
193028702d pad: Don't paste when middle-clicking on a link 2020-10-25 07:06:29 +00:00
Andrew Dassonville
bee1ae06d8 utils: Fix commit checking on detached HEAD 2020-10-24 16:22:01 -04:00
John McLear
cb5fcbb74e
editor: allow paste into links (#3802) 2020-10-24 16:59:03 +01:00
Richard Hansen
36aceb3aba hooks: Rewrite callAll and aCallAll for consistency
Rewrite the `callAll` and `aCallAll` functions to support all
reasonable hook behaviors and to report errors for unreasonable
behaviors (e.g., calling the callback twice).

Now a hook function like the following works as expected when invoked
by `aCallAll`:

```
exports.myHookFn = (hookName, context, cb) => {
  cb('some value');
  return;
};
```
2020-10-24 16:08:50 +01:00
Richard Hansen
79119baf58 hooks: Call the callback when done
If a hook function neither calls the callback nor returns a
(non-undefined) value then there's no way for the hook system to know
if/when the hook function has finished.
2020-10-24 16:08:50 +01:00
Richard Hansen
55939a0d7e hooks: Delete unused flatten function 2020-10-24 16:08:50 +01:00
Wouter
bd2343f131 Added nl translations for adminpage 2020-10-23 16:18:57 -04:00
translatewiki.net
73dd3ffdf4 Localisation updates from https://translatewiki.net. 2020-10-22 12:58:59 +02:00
chandi
94cb000e8f
plugins: include more data within padUpdate hook (#4425)
* Including more data at pad update event

* docs: new context fields in padUpdate

Co-authored-by: Pedro Beschorner Marin <pedrobmarin@gmail.com>
2020-10-21 18:04:03 +01:00
webzwo0i
1e7a9e1791
tests: better timeslider follow contents (#4421) 2020-10-21 10:05:58 +01:00
Richard Hansen
0eb0a07914 Use an ellipsis instead of two periods 2020-10-20 11:02:37 +01:00
Richard Hansen
2379ade7e9 Move out pad.modals.reconnecttimer trailing space 2020-10-20 11:02:37 +01:00
Richard Hansen
734fe9c297 Use jQuery methods to build DOM elements 2020-10-20 11:02:37 +01:00
Richard Hansen
a2554fff22 pad: Pop up an error message dialog box upon socket.io error 2020-10-20 10:01:49 +01:00
Richard Hansen
5b887396c3 pad: Check for null collabClient in socket.io event handlers 2020-10-20 10:01:49 +01:00
Richard Hansen
b1acf6143a pad: Delete do-nothing sendClientReady wrapper 2020-10-20 10:01:49 +01:00
Richard Hansen
a712ce457d gritter: Treat strings as text, not HTML
This forces users to use jQuery or DOM objects if they want
formatting, which helps avoid XSS vulnerabilities.
2020-10-20 10:01:49 +01:00
Richard Hansen
8463134125 pad: Improve rendering of uncaught exceptions
* Use jQuery to build the message HTML so that special characters in
    the error message, URL, etc. are properly escaped. This helps
    avoid XSS vulnerabilities.
  * Use bold text for the error message to make it stand out.
  * Add a line break between the error message and "in <url> at line
    <line>" so that the error message stands out more.
  * Use `<p>...</p>` instead of `</br>` to separate the parts of the
    popup.
  * Use CSS for spacing instead of `</br>`.
  * Grammar fixes (add a missing comma, "at" instead of "in").
2020-10-20 10:01:49 +01:00
Richard Hansen
d35dbaaacc gritter: Accept jQuery or DOM objects for title and text
Teach Gritter to accept anything that jQuery's `.append()` method
accepts for the title and text of a popup message. This makes it
easier to safely build HTML messages with proper escaping of special
characters (to prevent XSS vulnerabilities).
2020-10-20 10:01:49 +01:00
Richard Hansen
d680405f58 pad: Include .js URL in /jserror error report 2020-10-20 10:01:49 +01:00
translatewiki.net
2a8e11a49a Localisation updates from https://translatewiki.net. 2020-10-19 20:32:27 +02:00
translatewiki.net
105eb2651f Localisation updates from https://translatewiki.net. 2020-10-19 15:14:03 +02:00
Richard Hansen
4a25559a2d tests: Aggressively filter out non-.js files
This prevents errors when the directory contains Emacs backup files.
2020-10-14 10:38:52 +01:00
Richard Hansen
7f79d201e6 CSP: Move index.html inline code to separate .js file 2020-10-12 20:46:06 +01:00
translatewiki.net
09193150b6 Localisation updates from https://translatewiki.net. 2020-10-12 15:48:55 +02:00
Richard Hansen
a4927095ae CSP: Disable the indexCustomInlineScripts hook 2020-10-11 20:31:00 +01:00
Richard Hansen
052fbb944f
plugins: Delete noisy and useless debug message (#4409)
The debug statement mostly printed the following useless message over
and over, causing Travis CI logs to become truncated:

    [DEBUG] pluginfw - [ undefined ] returning
2020-10-11 09:51:53 +01:00
webzwo0i
a2328cd7f0
timeslider: bugfix: follow pad contents - only goToLineNumber if it exists (#4390) 2020-10-10 16:57:22 +01:00
Richard Hansen
048bd0f50d tests: Simplify API key reading
Also delete unused imports.
2020-10-08 22:50:18 +01:00
translatewiki.net
ce0b151159 Localisation updates from https://translatewiki.net. 2020-10-08 15:53:01 +02:00
John McLear
66df0a572f
Security: FEATURE REMOVAL: Remove all plain text password logic and ui (#4178)
This will be a breaking change for some people.  

We removed all internal password control logic.  If this affects you, you have two options:

1. Use a plugin for authentication and use session based pad access (recommended).
1. Use a plugin for password setting.

The reasoning for removing this feature is to reduce the overall security footprint of Etherpad.  It is unnecessary and cumbersome to keep this feature and with the thousands of available authentication methods available in the world our focus should be on supporting those and allowing more granual access based on their implementations (instead of half assed baking our own).
2020-10-07 13:43:54 +01:00
Richard Hansen
45bee54aa0 HTML export: Await async hook completion before processing results 2020-10-07 10:43:38 +01:00
Richard Hansen
661a89355f socketio: Mimic what Express does to get client IP address
This also makes it easier for plugins to get the client IP address.
2020-10-07 10:40:37 +01:00
Richard Hansen
ba6bdf35be Make the aceAttribClasses hook harder to misuse 2020-10-07 10:37:56 +01:00
Richard Hansen
5aa318a09b Call the aceAttribClasses hook synchronously
We could instead await the results of the hook, but then all callers
and their callers recursively would have to be converted to async, and
that's a huge change.
2020-10-07 10:37:56 +01:00
Richard Hansen
a8cf434d1d import: Replace the allowAnyoneToImport check with userCanModify
This reduces the number of hoops a user or tool must jump through to
import.
2020-10-05 18:48:16 +01:00
Richard Hansen
831528e8bc import: Allow import if pad does not yet exist 2020-10-05 18:48:16 +01:00
Richard Hansen
ed6fcefb67 webaccess: Fix pad ID extraction for import and export paths 2020-10-05 18:48:16 +01:00
Richard Hansen
f4eae40c6b webaccess: Check for read-only pad ID in userCanModify
This currently isn't absolutely necessary because all current callers
of `userCanModify` already check for a read-only pad ID themselves.
However:

  * This adds defense in depth.
  * This makes it possible to simply replace the import handler's
    `allowAnyoneToImport` check with a call to `userCanModify`.
2020-10-05 18:48:16 +01:00
Richard Hansen
377560eb51 express: Move general Express setup from webaccess.js
The `express-session`, `cookie-parser`, etc. middleware is not
specific to access checks.
2020-10-05 18:12:04 +01:00
Richard Hansen
821c06cc3a socketio: Reuse the express-session middleware 2020-10-05 18:12:04 +01:00
Richard Hansen
f7953ece85 socketio: Delete redundant authentication check
There's no need to perform an authentication check in the socket.io
middleware because `PadMessageHandler.handleMessage` calls
`SecurityMananger.checkAccess` and that now performs authentication
and authorization checks.

This change also improves the user experience: Before, access denials
caused socket.io error events in the client, which `pad.js` mostly
ignores (the user doesn't see anything). Now a deny message is sent
back to the client, which causes `pad.js` to display an obvious
permission denied message.

This also fixes a minor bug: `settings.loadTest` is supposed to bypass
authentication and authorization checks, but they weren't bypassed
because `SecurityManager.checkAccess` did not check
`settings.loadTest`.
2020-10-05 18:12:04 +01:00
Richard Hansen
3f8365a995 express: Use const and let instead of var
Also:
  * Sort imports.
  * Use single quotes.
  * Abbreviate module names.
2020-10-05 18:12:04 +01:00
Richard Hansen
b68969fbac webaccess: Simplify Express and express-session setup 2020-10-05 18:12:04 +01:00
Richard Hansen
275e5c31c8 webaccess: Wrap long lines 2020-10-05 18:12:04 +01:00
translatewiki.net
29ee63f2ba Localisation updates from https://translatewiki.net. 2020-10-05 15:56:29 +02:00
Richard Hansen
2db4b04af3 cookies: Use SameSite=None if in an iframe from another site 2020-10-04 08:57:44 +01:00
Richard Hansen
bf53162cdd cookies: Use Lax instead of Strict for SameSite 2020-10-04 08:57:44 +01:00
Richard Hansen
3ab0f30ac8 cookies: Use js-cookie to read and write cookies
Rather than reinvent the wheel, use a well-tested library to parse and
write cookies. This should also help prevent XSS vulnerabilities
because the library handles special characters such as semicolon.
2020-10-04 08:57:44 +01:00
Richard Hansen
d55edebddd cookies: Refactor pad_cookie.js
* Use the cookie functions from `pad_utils.js`.
  * Delete unused methods, variables, and parameters.
  * Simplify the logic.
  * Use an ES6 class instead of a weird literal thingy.
  * Use `const` instead of `var`.
2020-10-04 08:57:44 +01:00
translatewiki.net
891d2600fa Localisation updates from https://translatewiki.net. 2020-10-02 09:05:33 +02:00
webzwo0i
ceb09ce99a
security: Support proxy with rate limiting and include CI test coverage for nginx rev proxy (#4373)
Previously Etherpad would not pass the correct client IP address through and this caused the rate limiter to limit users behind reverse proxies.  This change allows Etherpad to use a client IP passed from a reverse proxy.

Note to devs: This header can be spoofed and spoofing the header could be used in an attack.  To mitigate additional *steps should be taken by Etherpad site admins IE doing rate limiting at proxy.*  This only really applies to large scale deployments but it's worth noting.
2020-10-01 10:39:01 +01:00
Richard Hansen
dbef630f44
i18n: Localize /admin pages (#4380)
Not every string was localized:

  * `/admin/plugins` has some CSS magic to draw the tables of plugins
    differently on narrow (mobile) screens, and the l10n library we
    use does not support that particular magic. The strings that were
    not localized are "Name", "Description", "Version", and "Time".
    These strings are only stuck in English when the page is viewed on
    a narrow screen; normal desktop users will see translated strings.
    The CSS magic ought to be replaced with something more robust
    (lots of nested `div`s); those remaining strings can be localized
    whenever that happens.

  * Strings from external sources such as plugin descriptions, error
    messages, and `settings.json` comments are not localized.
2020-10-01 10:15:27 +01:00
Richard Hansen
554eef7770 webaccess: Exempt /favicon.ico and /locales.json from auth checks 2020-09-29 19:40:24 +01:00
John McLear
5964055dec
package updates: update deps and resolve some potential security issues (#4369) 2020-09-29 13:21:35 +01:00
translatewiki.net
837ca6ec1e Localisation updates from https://translatewiki.net. 2020-09-28 17:15:23 +02:00
Richard Hansen
bf9d613e95
feature: New user-specific readOnly and canCreate settings (#4370)
Also:
  * Group the tests for readability.
  * Factor out some common test setup.
2020-09-28 11:22:06 +01:00
Richard Hansen
7bd5435f50 webaccess: Log hook errors 2020-09-28 09:35:42 +01:00
Richard Hansen
180983736d security: Enable authorize plugins to grant read-only access 2020-09-27 22:55:49 +01:00
Richard Hansen
304318b618 webaccess: Move pre-authn authz check to a separate hook
Before this change, the authorize hook was invoked twice: once before
authentication and again after (if settings.requireAuthorization is
true). Now pre-authentication authorization is instead handled by a
new preAuthorize hook, and the authorize hook is only invoked after
the user has authenticated.

Rationale: Without this change it is too easy to write an
authorization plugin that is too permissive. Specifically:

  * If the plugin does not check the path for /admin then a non-admin
    user might be able to access /admin pages.
  * If the plugin assumes that the user has already been authenticated
    by the time the authorize function is called then unauthenticated
    users might be able to gain access to restricted resources.

This change also avoids calling the plugin's authorize function twice
per access, which makes it easier for plugin authors to write an
authorization plugin that is easy to understand.

This change may break existing authorization plugins: After this
change, the authorize hook will no longer be able to authorize
non-admin access to /admin pages. This is intentional. Access to admin
pages should instead be controlled via the `is_admin` user setting,
which can be set in the config file or by an authentication plugin.

Also:
  * Add tests for the authenticate and authorize hooks.
  * Disable the authentication failure delay when testing.
2020-09-27 21:19:58 +01:00
Richard Hansen
411b278881 webaccess: Log all authentication successes/failures
This loses some of the granularity of the default HTTP basic auth
(unknown username vs. bad password), but there is considerable value
in having logging that is consistent no matter what authentication
plugins are installed.
2020-09-26 21:57:50 +01:00
Pedro Beschorner Marin
c56973ce74 Fix readOnly pad export
The export request hook wasn't testing if the pad's id was from a read-only
pad before validating with the pad manager.

This includes an extra step that makes the read-only id verification and also
avoids setting the original pad's id as the file's name.
2020-09-26 21:47:35 +01:00
Richard Hansen
ab5934cbda webaccess: Split authFailure hook into authnFailure and authzFailure
This makes it possible for plugins to return different pages to the
user depending on whether the auth failure was authn or authz.
2020-09-26 19:37:11 +01:00
Richard Hansen
889a3f7261 Bump Etherpad version in src/package-lock.json 2020-09-26 19:37:05 +01:00
Richard Hansen
3bb71e14d1 PadMessageHandler: Logging improvements 2020-09-26 19:36:52 +01:00
Richard Hansen
4332affba6 Fix typo in session check (sesion -> session) 2020-09-26 19:36:44 +01:00
Richard Hansen
02757079c0 security: Enable authorize plugins to grant modify-only access 2020-09-26 18:36:36 +01:00
Richard Hansen
6ed11b7605 PadMessageHandler: Avoid redundant access checks 2020-09-26 18:32:22 +01:00
Richard Hansen
1e3aa9edff pad: Revert back to sending CLIENT_READY on reconnect
Commit 0bb8d73ba2 fixed the author ID
that is saved in the socket.io sessioninfo when the client sends a
`CLIENT_READY` with `reconnect` set to true, so it is now safe to undo
the workaround from PR #3868.

Fixes #4331.
2020-09-26 18:32:04 +01:00
Richard Hansen
72ed1816ec security: Fix authz check for pad names with encoded characters
Also:
  * Minor test cleanups (`function` instead of arrow functions, etc.).
  * Add a test for a case that was previously not covered.
2020-09-26 10:47:27 +01:00
Richard Hansen
3c9ae57bb3 PadMessageHandler: Block Promise resolution until message is handled
Benefits:
  * More functions are now async which makes it possible for future
    changes to use await in those functions.
  * This will help keep the server from drowning in too many messages
    if we ever add acknowledgements or if WebSocket backpressure ever
    becomes reality.
  * This might make tests less flaky because changes triggered by a
    message will complete before the Promise resolves.
2020-09-26 10:47:03 +01:00
Richard Hansen
23131a501c tests: Rewrite import/export tests to use async and supertest 2020-09-26 10:46:16 +01:00
Richard Hansen
0bb8d73ba2 PadMessageHandler: Always save the author ID in the session info
Before, the author ID was only saved in the session info during the
initial CLIENT_READY, not when the client sent a CLIENT_READY due to a
reconnect. This caused the handling of subsequent messages to use an
undefined author ID.
2020-09-26 10:43:06 +01:00
translatewiki.net
6cde6f5a98 Localisation updates from https://translatewiki.net. 2020-09-24 15:54:49 +02:00
Richard Hansen
94f944160d security: Don't require express_sid if authn not required
This should make it possible to embed a pad in an iframe from another
site as long as `settings.requireAuthentication` is false.
2020-09-24 10:42:41 +01:00
Richard Hansen
53fd0b4f98 webaccess: Return 401 for authn failure, 403 for authz failure
This makes it possible for reverse proxies to transform 403 errors
into something like "upgrade to a premium account to access this
pad".

Also add some webaccess tests.
2020-09-24 10:41:58 +01:00
Richard Hansen
1bb44098df PadMessageHandler: Move handleMessage hooks after access check
Move the handleMessageSecurity and handleMessage hooks after the call
to securityManager.checkAccess.

Benefits:

  * A handleMessage plugin can safely assume the message will be
    handled unless the plugin itself drops the message, so it doesn't
    need to repeat the access checks done by the `handleMessage`
    function.
  * This paves the way for a future enhancement: pass the author ID to
    the hooks.

Note: The handleMessageSecurity hook is broken in several ways:

  * The hook result is ignored for `CLIENT_READY` and `SWITCH_TO_PAD`
    messages because the `handleClientReady` function overwrites the
    hook result. This causes the client to receive client vars with
    `readonly` set to true, which causes the client to display an
    immutable pad even though the pad is technically writable.
  * The formatting toolbar buttons are removed for read-only pads
    before the handleMessageSecurity hook even runs.
  * It is awkwardly named: Without reading the documentation, how is
    one supposed to know that "handle message security" actually means
    "grant one-time write access to a read-only pad"?
  * It is called for every message even though calls after a
    `CLIENT_READY` or `SWITCH_TO_PAD` are mostly pointless.
  * Why would anyone want to grant write access when the user visits a
    read-only pad URL? The user should just visit the writable pad URL
    instead.
  * Why would anyone want to grant write access that only lasts for a
    single socket.io connection?
  * There are better ways to temporarily grant write access (e.g., the
    authorize hook).
  * This hook is inviting bugs because it breaks a core assumption
    about `/p/r.*` URLs.

I think the hook should be deprecated and eventually removed.
2020-09-23 08:26:47 +01:00
Richard Hansen
0f6baac7b5
Revert "tests: Use wtfnode to determine why mocha isn't exiting" (#4315)
This reverts commit ae1142a799.

According to
https://github.com/ether/etherpad-lite/pull/4304#issuecomment-694833456
wtfnode always seems to exit with 0 even if the tests fail.
2020-09-22 22:47:26 +01:00
Richard Hansen
6011ef426f PadMessageHandler: Make sessioninfo tracking more robust
A session's sessioninfo could go away asynchronously due to a
disconnect. Grab a reference once and use it throughout the function
to avoid dereferencing a null sessioninfo object.
2020-09-22 14:11:02 +01:00
Richard Hansen
3365e944bf async-ify more functions, and await completion
Where feasible I put the await at the end of the function to
minimize the impact on latency.

My motivation for this change: Eliminate a race condition in tests I
am writing.
2020-09-22 14:10:44 +01:00
Richard Hansen
45ec8326f0 Add a new 'rejected' disconnect reason
This reason will be used in a future commit that will reject erroneous
messages.
2020-09-22 14:09:07 +01:00
Richard Hansen
a000a93dc6 Refactor startup/shutdown for tests
* `src/node/server.js` can now be run as a script (for normal
    operation) or imported as a module (for tests).
  * Move shutdown actions to `src/node/server.js` to be close to the
    startup actions.
  * Put startup and shutdown in functions so that tests can call them.
  * Use `await` instead of callbacks.
  * Block until the HTTP server is listening to avoid races during
    test startup.
  * Add a new `shutdown` hook.
  * Use the `shutdown` hook to:
      * close the HTTP server
      * call `end()` on the stats collection to cancel its timers
      * call `terminate()` on the Threads.Pool to stop the workers
  * Exit with exit code 0 (instead of 1) on SIGTERM.
  * Export the HTTP server so that tests can get the HTTP server's
    port via `server.address().port` when `settings.port` is 0.
2020-09-22 11:07:21 +01:00
Richard Hansen
a4be577ed1 SessionStore: Don't call callback until cached in DB layer 2020-09-21 23:21:05 +01:00
Richard Hansen
436cbb031d SessionStore: Avoid early DB.db dereference
Avoid dereferencing `DB.db` until it is used so that it is possible to
`require('SessionStore')` before calling `DB.init()`. (This is useful
when writing tests.)
2020-09-21 23:21:05 +01:00
Richard Hansen
bee91a0bd1 SessionStore: Use EC6 class syntax
This fixes a minor bug where the SessionStore constructor did not call
the base class constructor.
2020-09-21 23:21:05 +01:00
Richard Hansen
0504e07eb4 SessionStore: Wrap long line 2020-09-21 23:21:05 +01:00
Richard Hansen
90775cec0d SessionStore: Rename messageLogger to logger 2020-09-21 23:21:05 +01:00
Richard Hansen
4060db0daf SessionStore: Reduce unnecessary vertical space 2020-09-21 23:21:05 +01:00
Richard Hansen
5fb6bc1938 SessionStore: Use single quotes everywhere 2020-09-21 23:21:05 +01:00
Richard Hansen
012449101d SessionStore: Use const instead of var 2020-09-21 23:21:05 +01:00
Richard Hansen
5d2c438e3e SessionStore: Use an arrow function to avoid this juggling 2020-09-21 23:21:05 +01:00
Richard Hansen
de98852da6 SessionStore: Delete unused methods all, clear, length 2020-09-21 23:21:05 +01:00
Richard Hansen
346111250e utils: Fix promise creation accounting bug in promises.timesLimit
Before this change, `promises.timesLimit()` created `concurrency - 1`
too many promises. The only users of this function use a concurrency
of 500, so this meant that 499 extra promises were created each time
it was used. The bug didn't affect correctness, but it did result in a
large number of unnecessary database operations whenever a pad was
deleted. This change fixes that bug.

Also:
  * Convert the function to async and have it resolve after all of the
    created promises are resolved.
  * Reject concurrency of 0 (unless total is 0).
  * Document the function.
  * Add tests.
2020-09-21 23:16:32 +01:00
translatewiki.net
65942691b6 Localisation updates from https://translatewiki.net. 2020-09-21 16:02:42 +02:00
Richard Hansen
3886e95c83 SessionManager: Fix session expiration check
This bug was introduced in 8b0baa9679.
2020-09-19 21:10:36 +01:00
Sebastian Castro
12bd617f51
css: Improve toolbar responsiveness for small screen (#4322)
Until now, the "mobile layout" (with right toolbar on bottom of the screen) was displayed only when screen was smaller than 800px. It made the toolbar break for screen about 1000px when a lot of plugins are in the toolbar.
Now instead, we detect with javascript when the toolbar icons overflow the natural space available, and we switch in "mobile layout" in such case
2020-09-19 19:09:30 +01:00
Stefan Mueller
299bd962b6 Update version to 1.8.6 and add changelog informations 2020-09-18 21:14:19 +02:00
webzwo0i
85f52a2f23
tests: Plugin backend tests in ci (#4314) 2020-09-18 16:28:42 +01:00
translatewiki.net
dfe0368910 Localisation updates from https://translatewiki.net. 2020-09-17 16:40:29 +02:00
Joas Souza
8c04fe8775
Feature: Copy Pad without history (#4295)
New feature to copy a pad without copying entire history.  This is useful to perform a low CPU intensive operation while still copying current pad state.
2020-09-16 19:24:09 +01:00
Richard Hansen
b80a37173e security: Fix authorization bypass vulnerability
Before, a malicious user could bypass authorization restrictions
imposed by the authorize hook:

 * Step 1: Fetch any resource that the malicious user is authorized to
   access (e.g., static content).
 * Step 2: Use the signed express_sid cookie generated in step 1 to
   create a socket.io connection.
 * Step 3: Perform the CLIENT_READY handshake for the desired pad.
 * Step 4: Profit!

Now the authorization decision made by the authorize hook is
propagated to SecurityManager so that it can approve or reject
socket.io messages as appropriate.

This also sets up future support for per-user read-only and
modify-only (no create) authorization levels.
2020-09-15 21:40:25 +01:00
Richard Hansen
ae1142a799 tests: Use wtfnode to determine why mocha isn't exiting
If mocha hangs after running the tests, hit Ctrl-C and wtfnode will
print open files, open sockets, running timers, and running intervals.
Adding an `after` function that closes/stops all of those things will
ensure that mocha exits when it finishes running the tests.
2020-09-15 21:22:52 +01:00
Richard Hansen
e20731cb12 webaccess: Fix syntax error (missing close curly brace)
Somehow I introduced this bug in commit
2bc26b8ef8 but never noticed.
2020-09-15 21:21:13 +01:00
Richard Hansen
d2773609d1 PadMessageHandler: Fix assignment to const variable 2020-09-15 20:04:33 +01:00
Richard Hansen
5ac5b65aff Pad: Disable toolbar and import/export when reconnecting 2020-09-15 20:04:17 +01:00
Richard Hansen
6f28e415ec PadMessageHandler: Move code out of unnecessary closure (again) 2020-09-15 20:04:01 +01:00
Richard Hansen
9e6d3f3f63 tests: Add authentication, authorization bypass tests 2020-09-15 20:03:30 +01:00
Richard Hansen
80639fdc6a webaccess: Pass settings.users to the authenticate hook
Authentication plugins almost always want to read and modify
`settings.users`. The settings can already be accessed in a few other
ways, but this is much more convenient.
2020-09-15 19:26:24 +01:00
Richard Hansen
250e932f59 webaccess: Enforce creation of req.session.user by authn plugins
The authorization logic determines whether the user has already
successfully authenticated by looking to see if `req.session.user`
exists. If an authentication plugin says that it successfully
authenticated the user but it did not create `req.session.user` then
authentication will re-run for every access, and authorization plugins
will be unable to determine whether the user has been authenticated.
Return a 500 internal server error to prevent these problems.
2020-09-15 19:26:14 +01:00
Richard Hansen
80c0e2487d PadMessageHandler: Move code out of unnecessary closure
Also simplify the logic.
2020-09-15 19:23:48 +01:00
Richard Hansen
a261fdf430 i18n: Improve error logging when language JSON read fails
Before it only logged an error like this:

    SyntaxError: Unexpected string in JSON at position XYZ

Now it also logs the filename, making it easier to figure out where
the bad data is:

    failed to read file /path/to/etherpad-lite/src/locales/en.json: SyntaxError: Unexpected string in JSON at position XYZ
2020-09-15 15:32:43 +01:00
John McLear
38352c1f8c Merge branch 'develop' of github.com:ether/etherpad-lite into develop 2020-09-15 13:15:53 +01:00
John McLear
9f3cc7aae0 deps: update UeberDB to fix issue with Postgres which was causing 1.8.5 to fail on PG sites. 2020-09-15 13:15:28 +01:00
Richard Hansen
2bc26b8ef8 webaccess: Factor out common code 2020-09-15 10:44:23 +01:00
Richard Hansen
f9087fabd6 security: Check authentication in SecurityManager checkAccess
In addition to providing defense in depth, this change makes it easier
to implement future enhancements such as support for read-only users.
2020-09-15 10:43:23 +01:00
Richard Hansen
259b8d891d socketio: Use Error objects for socket.io connection errors
socket.io expects Error objects, otherwise it won't propagate the
message to the client.

Also do some cleanup.
2020-09-15 10:42:25 +01:00
Richard Hansen
0a836ced29 css: Line up line numbers with their rows
Tested with both `no-skin` and `colibris`.
2020-09-15 09:29:09 +01:00
webzwo0i
ec6b983917
packaging: remove pad_docbar.js (#4286)
package to reduce http requests: nice-select,
pad_automatic_reconnect, skin_variants, scroll, caretPosition

rename unorm in tar.json so it can be included
2020-09-13 19:01:28 +01:00
Richard Hansen
d0a16d23cb security: Fix authentication bypass vulnerability
Before, anyone who could create a socket.io connection to Etherpad
could read, modify, and create pads at will without authenticating
first.

The `checkAccess` middleware in `webaccess.js` normally handles
authentication and authorization, but it does not run for `/socket.io`
requests. This means that the connection handler in `socketio.js` must
handle authentication and authorization. However, before this change:
  * The handler did not require a signed `express_sid` cookie.
  * After loading the express-session state, the handler did not check
    to see if the user had authenticated.

Now the handler requires a signed `express_sid` cookie, and it ensures
that `socket.request.session.user` is non-null if authentication is
required. (`socket.request.session.user` is non-null if and only if
the user has authenticated.)
2020-09-13 18:56:31 +01:00
Richard Hansen
8b0baa9679 SecurityManager: Refactor checkAccess for readability, correctness
* Move session validity check and session author ID fetch to a
    separate function. This separate function can be used by hooks,
    making it easier for them to properly determine the author ID.
  * Rewrite the remainder of checkAccess. Benefits:
      - The function is more readable and maintainable now.
      - Vulnerability fix: Before, the session IDs in sessionCookie
        were not validated when checking settings.requireSession. Now,
        sessionCookie must identify a valid session for the
        settings.requireSession test to pass.
      - Bug fix: Before, checkAccess would sometimes use the author ID
        associated with the token even if sessionCookie identified a
        valid session. Now it always uses the author ID associated
        with the session if available.
2020-09-12 09:42:47 +01:00
Richard Hansen
8756fed80d PadMessageHandler: Use await instead of p.then() 2020-09-11 22:11:03 +01:00
Richard Hansen
3262ff1cb9 PadMessageHandler: Rename createSessionInfo to createSessionInfoAuth
The function doesn't create the session info -- it creates the auth
property of existing session info.
2020-09-11 22:11:03 +01:00
Richard Hansen
de792559cb PadMessageHandler: Use === instead of == for comparison 2020-09-11 22:11:03 +01:00
Richard Hansen
7f0770d684 PadMessageHandler: Invert logic to improve readability 2020-09-11 22:11:03 +01:00
Richard Hansen
d4db091d1d PadMessageHandler: Simplify handleClientReady a bit
Before, this function referred to the same author ID in different ways
in different places. Use one spelling to make the code easier to read.
2020-09-11 22:11:03 +01:00
Richard Hansen
ed3c82e8c3 Use null, not "null", if sessionID cookie doesn't exist
`decodeURIComponent(null)` returns the string `'null'`, which we don't
want.
2020-09-11 22:10:04 +01:00
translatewiki.net
24978daeb0 Localisation updates from https://translatewiki.net. 2020-09-10 18:36:59 +02:00
John McLear
5dfae625b9 Package Lock update 2020-09-09 18:15:47 +01:00
John McLear
c8361a211a bump ueber 2020-09-09 14:41:03 +01:00
Stefan Mueller
e64a269a65 Update version to 1.8.5 2020-09-08 22:09:56 +02:00
John McLear
7258d75cc5 bumping ueber 2020-09-08 16:03:15 +01:00
Richard Hansen
6c2a361935 import: Use the correct author ID when using sessions
There are two different ways an author ID becomes associated with a
user: either bound to a token or bound to a session ID. (The token and
session ID come from the `token` and `sessionID` cookies, or, in the
case of socket.io messages, from the `token` and `sessionID` message
properties.) When `settings.requireSession` is true or the user is
accessing a group pad, the session ID should be used. Otherwise the
token should be used.

Before this change, the `/p/:pad/import` handler was always using the
token, even when `settings.requireSession` was true. This caused the
following error because a different author ID was bound to the token
versus the session ID:

> Unable to import file into ${pad}. Author ${authorID} exists but he
> never contributed to this pad

This bug was reported in issue #4006. PR #4012 worked around the
problem by binding the same author ID to the token as well as the
session ID.

This change does the following:
  * Modifies the import handler to use the session ID to obtain the
    author ID (when appropriate).
  * Expands the documentation for the SecurityManager checkAccess
    function.
  * Removes the workaround from PR #4012.
  * Cleans up the `bin/createUserSession.js` test script.
2020-09-08 15:04:17 +01:00
Richard Hansen
db0bcb524e SecurityManager: Use constants for returned rejections
This reduces the chances of a typo-induced bug.
2020-09-08 14:53:28 +01:00