ban_provider not found

Created on 23 December 2024, about 1 month ago

Problem/Motivation

In the 'Add autoban rule' config page we see: 'Warning message
List ban providers is empty. You have to enable at least one Autoban providers module. '
and no providers are listed on the drop-down.

Looking at the Controller code - getBanProvidersList() is looking for a service with name 'ban_provider'.
Core module 'ban' is enabled and in README etc is one of the expected ban_providers. One of its 2 services is called 'ban_ip.manager'

The serialized Services $value for ban_ip.manager (formatted) is:

Array(
    [class] => Drupal\ban\BanIpManager
    [arguments] => stdClass Object (
            [type] => collection
            [value] => Array (
                    [0] => stdClass Object (
                            [type] => service
                            [id] => database
                            [invalidBehavior] => 1
                        )
                )
        )
    [arguments_count] => 1
)

This general format (now?) being used by Drupal does not seem to match the code, so it seems no values are ever going to be found.

See also https://www.drupal.org/project/autoban/issues/3328787 πŸ› "No ban manager for rule" after updating core to 9.5.0 Fixed ("No ban manager for rule" after updating core to 9.5)

Steps to reproduce

Enable this module and ban module, goto Add autoban rule (admin/config/people/autoban/add)

Proposed resolution

Change code to look for ban's service (if ban module still works), something like:

      if ($service_id == 'ban.ip_manager') { // etc
        $service = $container->get($service_id);
        $banProvidersList[$service_id] = ['name' => $service_id, 'service' => $service];
      }

Or update documentation for valid ban_provider

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

1.10

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom Jons

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Jons
  • πŸ‡ΊπŸ‡¦Ukraine goodboy Kharkiv, Ukraine

    Hi, @jons
    Thank you for using Autoban
    You should enable Autoban submodule (for the Ban provider is the Autoban Core Ban Provider).

    I wrote in README.md

    "You must enable Database Logging core module and at least one
    IP Ban Provider by enabling submodules."

    Perhaps I clumsily formulated the requirements. Maybe you will help me with this.

    I also tried working Autoban on Drupal 9.5.11, it found the Ban provider.

  • πŸ‡ΊπŸ‡¦Ukraine goodboy Kharkiv, Ukraine

    I've changed README.md

  • πŸ‡¬πŸ‡§United Kingdom Jons

    Hi @goodboy
    I think the confusion was needing the ban module and autoban_ban.
    As autoban_ban is just a a shim onto the (core) ban module

    public function getBanIpManager(Connection $connection) {
        return new BanIpManager($connection);
      }
    

    Would it be worth removing this and linking to ban directly by default, or always just using advban? The core ban is scheduled to become contrib shortly so may not be so reliably present in future.

  • πŸ‡ΊπŸ‡¦Ukraine goodboy Kharkiv, Ukraine

    Hi, @jons
    Thank you for your thoughts.
    It was designed as an open system and third party IP ban providers can use the integration with the Autoban module.
    I want to keep the structure.

Production build 0.71.5 2024