pad.pub0.org/doc/api
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
..
api.md
changeset_library.md formatting: bulk remove trailing whitespaces 2019-10-20 02:09:22 +02:00
editbar.md
editorInfo.md
embed_parameters.md formatting: bulk remove trailing whitespaces 2019-10-20 02:09:22 +02:00
hooks_client-side.md hooks: allow to set the duration of the gritter notification when a new chat message arrives 2020-03-27 02:39:29 +01:00
hooks_overview.md docs: Revise hooks overview section 2020-09-05 20:34:47 +01:00
hooks_server-side.md PadMessageHandler: Move handleMessage hooks after access check 2020-09-23 08:26:47 +01:00
http_api.md Feature: Copy Pad without history (#4295) 2020-09-16 19:24:09 +01:00
pluginfw.md Typos and minor fixes in bin, doc, and root 2017-09-14 13:33:27 +02:00
toolbar.md formatting: bulk remove trailing whitespaces 2019-10-20 02:09:22 +02:00