Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

DKAN Automated Protection

Security covered Under active development 38 sites

Part of the Dkan ecosystem · 15 projects

This module automatically enables DKAN's degraded service mode when database connections exceed a configured threshold. This prevents slow queries from overwhelming the database and ensures the site remains accessible by limiting complex requests.

This module is currently under development following the practice of Contrib First. It should be considered incomplete and under construction while in alpha release.

Features

The DKAN APIs allow users to query and filter datasets and provide a powerful tool for looking at public data. This power however has the potential to create some slow queries that tend to stack up. If the site is under significant bot or AI traffic, it is possible that the maximum number of allowed database connections may be exceeded. If that happens, the database goes away for all requests over that connection limit. Rather than let that happen arbitrarily, this module aims to dynamically activate the "Degraded service mode" already provided as a manual option as part of DKAN. This mode essentially limits the types of queries that can be made, to those that are not so complex or long running, while still allowing the site to function for most of its features.

User Interface

  • setting to disable automated protection mode (so it can be turned off without disabling the module).
  • setting for number of max connections allowed by the server
  • setting for the % of max connections that should enable protected mode
  • setting to run this on cron or not
  • Log when protected mode is enabled or disabled including the information related to the the status of the database.

Checks performed

Currently this module only performs one check. It checks the current number of database connections and takes action only if it is above the threshold set for the percentage of maximum connections allowed. In the future, more checks may be added.

External monitoring

The module provides and updates a static file 'public://dkan_api_status.json' so that any other monitor or front-end check can know the current state of the degraded service mode without the check creating an extra hit to the database. The file gets updated whenever this module changes the degraded service mode state. RISK: There is a risk that if someone manually changes the degraded service mode of the site, this module will not know about it, so the file may not reflect the manual change.

Normal mode (degraded service mode off)

{
    "mode": "normal",
    "modified": {
        "date": "2026-09-20",
        "time": "22:26:00"
    }
}

Protected mode (degraded service mode on)

{
    "mode": "protected",
    "modified": {
        "date": "2026-09-20",
        "time": "22:30:00"
    }
}

Drush Commands

  • dkan-automated-protection:run-checks This runs the checks and enables or disables DKAN's degraded service mode accordingly. The command provides a way to run this via any job runner that you use.
  • dkan-automated-protection::mode [on or off] This allows you to toggle the automated protection. Turning the mode off is equivalent to uninstalling the module, but will not cause a loss of other settings.
  • dkan-automated-protection:degraded-mode [on or off] This is a replacement for 'dkan:datastore:degraded-mode' and does the same thing, but this also updates the dkan_api_status.json file.
  • dkan-automated-protection:db-info This pulls the same information that the check status uses to get the db status. It outputs it to the terminal for human use.

Requirements

This project requires the following modules:

Installation

Install as you would normally install a contributed Drupal module. For more information, see Installing Drupal Modules.

Using Composer:

composer require drupal/dkan_automated_protection

Post-Installation / Configuration

When this module is enabled, it provides settings for determining when or if it should enable DKAN's degraded service mode.

  1. Navigate to Administration > DKAN > DKAN Automated Protection (/admin/dkan/dkan-automated-protection).
  2. Configure thresholds for database connection monitoring and automatic degraded service mode activation.
  3. Save configuration.
Drupal 11 · not 10

Ask your assistant about DKAN Automated Protection

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • dkan Drupal core
  • dkan_datastore Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Sep 2026
Latest release
1 month ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Releases

Version Type Core PHP Release date
1.0.0 Stable 11 Sep 21, 2026
1.0.x-dev Dev Sep 18, 2026