Problem/Motivation

Currently, there is no way to whitelist / allowlist certain IPs / IP-Ranges

Steps to reproduce

Proposed resolution

Implement the ability to provide a whitelist / allowlist to always allow certain IPs / IP-Ranges.

Issue fork drupal-3392147

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Issue fork ban-3392147

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

lukassykora created an issue. See original summary.

cilefen’s picture

Version: 10.1.x-dev » 11.x-dev
Status: Needs work » Active

lukassykora’s picture

Version: 11.x-dev » 10.1.x-dev
Status: Active » Needs review
lukassykora’s picture

StatusFileSize
new15.18 KB
cilefen’s picture

Version: 10.1.x-dev » 11.x-dev

I am moving this back to the feature request branch.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests, +Needs issue summary update

Tagging for test coverage.

Also issue summary appears incomplete. There are several sections of the template that should be left, and this appears to be adding new UI change, possibly API. Also works mentioning the need for this feature helps in the review.

Thanks.

quietone’s picture

Title: Whitelist IP for a Ban module. » Add an allowed IP list to the Ban module
Issue summary: View changes

@lukassykora, thanks for making an MR for this suggestion!

There is an outstanding issue for Drupal core to remove the terms 'whitelist' and 'blacklist' from the code base. There are links in the Issue Summary for this work that explains the reasons, #2993575: [meta] Remove usage of "blacklist", "whitelist", use better terms instead. Because of that the patch needs to updated.

Like #7 mentions the standard template allows us to coordinate work on an issue. Since it is no longer here I have restores the standard template and updated the remaining tasks and it to remove 'whitelist'. I also updated the title.

KurtTrowbridge made their first commit to this issue’s fork.

kurttrowbridge’s picture

StatusFileSize
new35.37 KB

I added a new fork, 3392147-allowed-ips, with the patch provided in #5 plus some inclusive language changes. (Sorry if I didn't do that right—the amount that the existing MR had changed in unrelated files threw me off, so I was hesitant to try to build on top of it.) I also did a little bit of formatting cleanup, but that probably wasn't exhaustive.

One thing I'm confused by is that when I look at the allowlist, the IP addresses won't show up in the column (see attached screenshot)—something seems off with how the ID and Allowlisted IP properties are defined and saved, but I haven't yet figured out what. Additionally, it looks like the IP address is intended to be saved as the entity ID; this works for IPv4 addresses, but causes a fatal error ("Invalid character in Config object name") when allowing IPv6 addresses due to the colons (:) in the address.

quietone’s picture

Status: Needs work » Postponed

The Ban Module was approved for removal in #1570102: [Policy] Deprecate Ban module.

This remains Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.

The deprecation work is in #3482198: [meta] Tasks to deprecate the Ban module and the removal work in #3488827: [meta] Tasks to remove Ban module.

Ban will be moved to a contributed project after the Drupal 12.x branch is open.

quietone’s picture

Assigned: lukassykora » Unassigned

I also meant to change this to un-assigned.

anybody’s picture

Contrib request in advban module: #3544163: IP Whitelist

Still a very valid request!

lukassykora changed the visibility of the branch 3392147-d11-compatibility to hidden.

goodboy’s picture

The protected list was added to the https://www.drupal.org/project/advban 1.9

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

mstrelan’s picture

Project: Drupal core » Ban
Version: main » 1.0.x-dev
Component: ban.module » Code
Status: Postponed » Needs work

Moved to contrib module queue

anybody’s picture

Related issues: +#3544163: IP Whitelist

Let's proceed here. An allowed list would be really helpful, at least if this won't get merged with the more powerful advban module.

grevil changed the visibility of the branch 3392147-whitelist-ip-for to hidden.

mstrelan’s picture

Version: 1.0.x-dev » 1.1.x-dev

grevil changed the visibility of the branch 3392147-allowed-ips to hidden.

grevil changed the visibility of the branch 11.x-3392147-allowed-ips to hidden.

anybody’s picture

Changed merge target to 1.1.x - please rebase

anybody’s picture

Mhm I'm not really sure MR!6 is a good approach. Won't this result in many many config entities per (whitelisted) IP?
Let's better add a settings page and a textarea IMHO. KISS! ;)

grevil’s picture

Thanks @mstrelan, can you also set it as a default branch in https://git.drupalcode.org/project/ban/-/branches?

grevil’s picture

@anybody, what the hell? I wrote a long pro / contra for this, seems to be in an unrelated issue now, great. xD

But yea I agree, currently working at the settings variation.

grevil changed the visibility of the branch 3392147-add-an-allowed to hidden.

grevil’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs tests, -Needs issue summary update

Alright, that's it, working splendid!

Please review!

grevil’s picture

Status: Needs review » Needs work

Let me quickly add and fix up the tests.

grevil’s picture

Status: Needs work » Needs review

No idea what's up with the drupal gitlab servers, but I added further tests through https://git.drupalcode.org/issue/ban-3392147/-/commit/bfe01274bfdd51cc96..., for some reason, there are not in the MR (yet?).

Please review anyway!

anybody’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @grevil for this implementation and also adding tests. LGTM and as soon as we have green tests, RTBC from my side. But would be great if @mstrelan could do the final review and merge then :)

grevil’s picture

I don't think he added us as maintainers, but still wants to review everything by himself.

  • grevil committed 5308b842 on 1.0.x
    feat: #3392147 Add an allowed IP list to the Ban module
    
grevil’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • grevil committed ee2de6b9 on 1.1.x
    feat: #3392147 Add an allowed IP list to the Ban module
    
    
    (cherry picked...

  • grevil committed e25f2c98 on 1.0.x
    Revert "feat: #3392147 Add an allowed IP list to the Ban module"
    
    This...
mstrelan’s picture

Just want to point out we need to be careful with BC. Adding a required constructor param to BanMiddleware could cause a BC break if people are extending this class or instantiating it directly. Ideally we would have ?ConfigFactoryInterface $config_factory = NULL and throw a deprecation if NULL is passed. Then load it via Drupal::service in that instance.

grevil’s picture

@mstrelan yea, I guess a 2.x branch could've made more sense, so we can adjust things more freely.

There is no 1.1.x release yet. We could still create the 2.x branch and move everything over there, but I'd say we keep it as is.

grevil’s picture

I created #3575604: Remove introduced breaking changes in 1.1.x, to fix the breaking changes.

anybody’s picture

anybody’s picture

I created #3578480: Worth caching allowed IP list in middleware? as follow-up because I'm unsure about possible performance implications in the middleware.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.