CONTENTS OF THIS FILE
---------------------

 * Introduction
 * Requirements
 * Installation
 * Configuration
 * How It Works
 * Maintainers


INTRODUCTION
------------

BotBuster provides lightweight DDoS protection for Drupal sites by requiring
browsers to pass a JavaScript challenge before accessing protected paths.

It works as an HTTP middleware that intercepts requests to configured paths and
serves a browser verification challenge page. Only clients that can execute
JavaScript and generate a valid token are allowed through. This effectively
blocks simple bots, scrapers, and automated tools that do not run JavaScript.

 * For a full description of the module, visit the project page:
   https://www.drupal.org/project/botbuster

 * To submit bug reports and feature suggestions, or track changes:
   https://www.drupal.org/project/issues/botbuster


REQUIREMENTS
------------

This module requires no modules outside of Drupal core.

A private file system path must be configured in settings.php:

  $settings['file_private_path'] = 'sites/default/files/private';


INSTALLATION
------------

 * Install as you would normally install a contributed Drupal module.
   Visit https://www.drupal.org/node/1897420 for further information.


CONFIGURATION
-------------

 1. Navigate to Administration > Configuration > System > BotBuster.
 2. Enable DDoS protection.
 3. Enter the paths you want to protect, one per line. Wildcards (*) are
    supported. Examples:
      /search
      /search/*
      /catalog/*
      *facet*
 4. Configure the token lifetime (how long a verified browser stays valid).
 5. Customize the challenge page text (title, heading, description, etc.).
 6. Save configuration. The challenge page and protected paths files are
    generated automatically.
 7. If your site is behind a CDN/reverse proxy, ensure the BotBuster token
    cookie is forwarded to origin. By default the cookie name is
    <code>botbuster_token</code> (configurable in the module form).


HOW IT WORKS
------------

BotBuster operates at the HTTP middleware level for minimal performance impact:

 1. When a request arrives for a protected path, the middleware checks for a
    valid botbuster_token cookie.
 2. If no valid token exists, a challenge page is served instead of the
    requested page. The challenge page runs JavaScript that stores a
    server-signed browser token as a cookie.
 3. After successful verification of a GET request, the browser reloads the
    originally requested page, preserving its query string and fragment.
    Subsequent requests include the token cookie and pass through.
 4. A challenged POST or other non-GET request is not redirected or replayed.
    Verification completes and the page asks the visitor to return to the
    form, review it, and submit again. Uploaded files may need to be selected
    again. BotBuster does not store submitted fields, passwords, or uploads.
    Verified submissions pass through with their original method and body.
    AJAX and API callers receive the challenge HTTP 503 response and must
    establish verification through a GET before explicitly retrying.

The challenge page and protected paths configuration are pre-generated as
static files in the private file system. This means the middleware does not
need to bootstrap Drupal services on every request, keeping overhead minimal.

CDN / REVERSE PROXY SETUPS
--------------------------

BotBuster requires the token cookie to reach Drupal origin on protected-path
requests. If a CDN/reverse proxy strips unknown cookies, users can be trapped
in a repeated challenge loop.

Default cookie name: <code>botbuster_token</code>

If your edge only forwards allowlisted patterns, either:
 - allowlist <code>botbuster_token</code>, or
 - configure BotBuster to use a cookie name that matches your allowlist.

Common examples:

 - Fastly:
   update VCL to preserve the BotBuster cookie in <code>req.http.Cookie</code>
   when forwarding requests to origin.

 - Upsun / Platform.sh:
   add the BotBuster cookie to the route cookie allowlist in
   <code>.platform/routes.yaml</code>.

 - Varnish:
   in <code>vcl_recv</code>, keep/pass the BotBuster cookie instead of dropping
   it for matching requests.

 - Cloudflare:
   verify cache/rules configuration does not strip the BotBuster cookie before
   forwarding to origin.


TESTING
-------

Run the PHP Unit and Kernel suites using the supported Drupal core testing
bootstrap. Kernel tests require an isolated test database. Drupal 10 and 11
must both be tested.

Run the standalone challenge navigation tests with Node.js 22 or newer:

  node --test tests/js/challenge.test.mjs

After an update, run database updates and rebuild Drupal caches to regenerate
the private challenge HTML and refresh its JavaScript cache-busting URL.


MAINTAINERS
-----------

 * Valentin Zsigmond (vzsigmond) - https://www.drupal.org/u/vzsigmond
