Skip to content

Add-on upgrade guide doesn't mention the __nonce form token now required on dosql, AJAX and do_* requests #464

Closed

Description

@caseysoftware

Since #400, every dosql POST and every a=do_* / a=domodsql request must carry the session's form token as __nonce. Without it, the request is redirected with "Your form has expired or did not come from this site". w2p_add_form_tokens() adds the token to <form method="post"> automatically, but it can't add it to:

  • AJAX posts ($.ajax, $.post, fetch) to a dosql handler
  • GET links to a=do_* actions
  • forms built in JavaScript

The manual's Updating Add On Modules for v5.0 section (web2project/manual, manuscript/app-b-add-on-modules.txt) doesn't mention the token. The failure is silent: the AJAX call gets the whole redirect page back. In the HelpDesk add-on, the requestor lookup pasted that HTML page into the Requestor field.

Suggested fix: add a "Form tokens (CSRF)" subsection under Other changes that affect modules:

  • POST forms: nothing to do.
  • AJAX: send __nonce: '<?php echo $AppUI->getFormToken(); ?>' (as modules/system/customfields/addedit.php does).
  • GET links that change data: append &__nonce= plus the token, or better, make them POST forms.
  • Handlers that change data outside dosql/do_* (for example a configure page that saves on POST) must call $AppUI->checkFormToken() themselves.

Also add a grep for $.ajax\|$.post\|fetch( to the "Find what your module uses" block.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions