Commit Graph

337 Commits

Author SHA1 Message Date
Richard Hansen 945e6848e2 SessionStore: Delete DB record when session expires
This only deletes records known to the current Etherpad instance --
old records from previous runs are not automatically cleaned up.
2022-01-17 21:45:56 -05:00
Richard Hansen 72cd983f0f SessionStore: Option to update DB record on `touch()` 2022-01-17 21:45:52 -05:00
Richard Hansen b991948e21 SessionStore: Don't write DB record if already expired 2022-01-17 21:33:58 -05:00
Richard Hansen 4d498725c7 SessionStore: Improve cookie expiration check
* Don't mutate `sess.cookie.expires`.
  * Allow `sess.cookie` to be nullish.
  * Always compare `Date` objects.
2022-01-17 18:17:40 -05:00
Richard Hansen fd9b770579 PadManager: Refactor `padList` to avoid duplicate loads 2022-01-02 20:44:42 -05:00
Dirk Jagdmann 2e4c546c7f Pad: Add new `.spliceText()` method
Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2021-12-21 17:00:18 -05:00
Richard Hansen 4733c7d8d3 SessionStore: Promisify to the extent permitted by express-session 2021-12-18 18:29:04 -05:00
webzwo0i 694d3f630e SessionStore: Propagate database errors to express-session
Send a 500 HTTP status code to the client if the session entry could
not be fetched from the database. This is useful in case the database
is busy and can't respond to the query in time. In this case we want
to abort the client connection as soon as possible.

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2021-12-18 18:29:04 -05:00
Richard Hansen 7572040836 Pad: Simplify `Pad.copy()` logic 2021-12-18 18:28:58 -05:00
webzwo0i 0040f5984e db: await more database operations
Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2021-12-18 18:23:27 -05:00
Richard Hansen b1d0848701 Pad: Improve readability of `appendText` 2021-12-16 00:48:07 -05:00
Richard Hansen a6bf7816ce Pad: Simplify `setText` 2021-12-16 00:48:07 -05:00
Richard Hansen d94f380141 API: Fix race conditions in `setText`, `appendText`, `restoreRevision` 2021-12-14 01:02:00 -05:00
Richard Hansen a370cfa5c6 Pad: Don't create no-op revisions 2021-12-14 01:02:00 -05:00
Richard Hansen 56b7671422 Pad: Return new rev number from `appendRevision()` 2021-12-14 01:02:00 -05:00
John McLear 6cca27dea6 API: `getText` with old revision should only return text, not atext
Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2021-12-05 18:50:39 -05:00
Richard Hansen a02e45499d Use the new AttributeMap and Changeset APIs 2021-11-28 23:47:27 -05:00
Richard Hansen f00b1ae89b Merge branch 'master' into develop 2021-11-28 23:10:45 -05:00
Richard Hansen 19909eae53 ImportEtherpad: Rigorously check imported data 2021-11-28 22:28:55 -05:00
Richard Hansen 885ff3bcde Pad: Move `padLoad` hook invocation to `PadManager.js`
This puts global state change logic with the rest of the global state
management logic. This also makes it possible to create temporary Pad
objects without triggering plugin actions.
2021-11-28 22:28:55 -05:00
Richard Hansen f7d4abdabe Pad: Inject the database dependency 2021-11-28 22:28:55 -05:00
Richard Hansen 7c870f8a58 Pad: Add strict validation checks 2021-11-28 22:28:55 -05:00
Richard Hansen 777d045246 GroupManager: Clean up any mappings when deleting a group 2021-11-28 14:06:47 +00:00
Richard Hansen 5b37a56197 GroupManager: Use `.setSub()` and parallel queries to avoid races
This also simplfies the code.
2021-11-27 22:20:03 -05:00
Richard Hansen 9d63700da0 SessionManager: Use `.setSub()` and parallel queries to avoid races
This also simplfies the code.
2021-11-27 22:20:03 -05:00
Timon Engelke 3070cee9ca Delete group after removing it from the group list 2021-11-27 22:20:03 -05:00
Timon Engelke 09c9e32d72 Delete session after corresponding group2session and author2session 2021-11-27 22:20:03 -05:00
Richard Hansen 89fe40e080 Changeset: Migrate from `OpIter` to `deserializeOps()` 2021-11-23 01:21:49 -05:00
Richard Hansen dab881139d Pad: Fix `copyPadWithoutHistory` apool corruption bug 2021-11-22 18:40:22 -05:00
Richard Hansen d74dd235a4 Changeset: Replace `appendATextToAssembler()` with a generator 2021-11-22 18:10:37 -05:00
Timon Engelke b0a7237443 Fix comparison between CustomError and string 2021-11-12 23:40:20 +01:00
Richard Hansen 9f66ffbc3b Pad: Delete no-op call to `SmartOpAssembler.appendOpWithText()` 2021-11-07 22:42:31 -05:00
Richard Hansen 4c2f7f9a11 chat: Rename `userId` to `authorId`, `userName` to `displayName` 2021-11-01 01:54:28 -04:00
Richard Hansen 0f47ca9046 chat: Plumb message object end to end
This will make it possible for future commits to add hooks that allow
plugins to augment chat messages with arbitrary metadata.
2021-11-01 01:54:28 -04:00
Richard Hansen 23037280a8 Pad: Simplify `getChatMessages()` 2021-11-01 01:54:28 -04:00
webzwo0i f7f5e3dad8 setText: prevent adding useless revision in case the pad text did not
change
2021-10-29 02:29:45 -04:00
Richard Hansen 6f2f20233f lint: Fix straightforward ESLint errors 2021-05-12 11:26:35 +02:00
Richard Hansen 59c03bde20 lint: Re-run `eslint --fix` 2021-05-12 11:26:35 +02:00
Richard Hansen b040ebf419 Revert "PadMessageHandler: Use a `Map` for `sessioninfos`"
Switching to a Map broke ep_webrtc and maybe other plugins.

This reverts commit eeead46437.
2021-05-05 18:09:10 -04:00
Richard Hansen eeead46437 PadMessageHandler: Use a `Map` for `sessioninfos`
Maps are a bit more flexible, have clearer semantics, and have a
convenient `size` property.
2021-05-03 01:35:11 -04:00
webzwo0i 3a5af19492 AuthorManager: await for more db methods 2021-04-20 11:27:44 -04:00
webzwo0i 35797e57fc AuthorManager: await db.set in createAuthor 2021-04-20 11:27:44 -04:00
Richard Hansen 329d037431 Simplify read-only pad ID checks 2021-04-12 22:51:06 -04:00
pcworld 3c71e8983b Fix read only pad access with authentication
Before this commit, webaccess.checkAccess saved the authorization in
user.padAuthorizations[padId] with padId being the read-only pad ID,
however later stages, e.g. in PadMessageHandler, use the real pad ID for
access checks. This led to authorization being denied.

This commit fixes it by only storing and comparing the real pad IDs and
not read-only pad IDs.

This fixes test case "authn user readonly pad -> 200, ok" in
src/tests/backend/specs/socketio.js.
2021-04-12 22:51:06 -04:00
Richard Hansen fcf43a7089 stats: Expose ueberDB metrics 2021-03-08 22:32:39 +00:00
John McLear ce83181ac3
Lgtm bugfixes (#4838)
* code tidy up: always evaluates

* tidy up: is always true

* tidy up: remove unused code

* always true/false variables

* unused variable

* tidy up: remove unused code in caretPosition.js

* for squash: Revert "tidy up: remove unused code in caretPosition.js"

The `if` condition was previously always true, so the body should be
preserved. If the body is preserved, other logic can be deleted. I
opened PR #4845 to clean it all up.

This reverts commit 75b03e5a7dc1ff9a8728ed2341fd9fe970d0615f.

* for squash: simplify

* for squash: Explain that the getter is used for its side effects

It's very weird to call a getter without using its return value. Add a
comment explaining why this is done so that the reader doesn't get
confused.

* for squash: Revert "tidy up: remove unused code"

The exception test was the purpose of the code.

This reverts commit 85153b167613b2513fff99e22b8ded8ea1e4547b.

* for squash: Log the tsort results

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
2021-02-22 08:26:35 +00:00
John McLear 3ed4ac649c lint: PadManager.js 2021-02-21 21:02:59 -05:00
freddii ea202e41f6 docs: fixed typos 2021-02-03 00:30:07 +01:00
Richard Hansen 53092fa7af db/Pad: Call padCopy and padRemove hooks asynchronously 2021-01-28 09:36:22 +00:00
John McLear 8fb6912fc9 lint: src/node/db/SessionStore.js 2021-01-25 22:53:09 -05:00