Skip to content

Add IP-based user banning#111

Merged
monorkin merged 2 commits intomainfrom
ip-ban
Nov 27, 2025
Merged

Add IP-based user banning#111
monorkin merged 2 commits intomainfrom
ip-ban

Conversation

@kevinmcconnell
Copy link
Copy Markdown
Collaborator

This adds the ability to ban a user by their IP address.

When an admin is viewing a user profile, a new "Ban user" button is present. Clicking on that will:

  • Create a ban on the IP addresses that were tracked for that user's sessions
  • Remove all the messages authored by that user
  • Log the user out immediately

In addition, that user will no longer be shown in most user lists in the app. They are still shown to admins, in account settings. Viewing their profile from there will now show a "Remove ban" button which can be used to restore their access (it doesn't restore their messages though -- those are already gone -- it just removes the blocks so they can log in again).

/cc @monorkin @jzimdars

screenshot-2025-11-26_13-38-58 screenshot-2025-11-26_13-41-28 screenshot-2025-11-26_13-42-12

This adds the ability to ban a user by their IP address.

When an admin is viewing a user profile, a new "Ban user" button is
present. Clicking on that will:

- Create a ban on the IP addresses that were tracked for that user's
  sessions
- Remove all the messages authored by that user
- Log the user out immediately

In addition, that user will no longer be shown in most user lists in the
app. They are still shown to admins, in account settings. Viewing their
profile from there will now show a "Remove ban" button which can be used
to restore their access (it doesn't restore their messages though --
those are already gone -- it just removes the blocks so they can log in
again).

private
def reject_banned_ip
head :too_many_requests if Ban.banned?(request.remote_ip)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, how come you went with too many requests?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was on the fence between that and 403. 429 felt a little more like "we're not accepting traffic from you right now", especially if we end up doing temporary bans. But I could easily be convinced that 403 is more appropriate. I think either one works.

@monorkin monorkin merged commit 59b322e into main Nov 27, 2025
11 checks passed
@jeremy jeremy deleted the ip-ban branch December 3, 2025 06:16
@TyIsI
Copy link
Copy Markdown

TyIsI commented Feb 11, 2026

Questions as I noticed all other features were closed:

  • How would this prevent a user from just using a rotating vpn?
  • Alternatively, would this also prevent a legit user from logging in if they were say working from a coffee shop or venue that shares the same IP address as a previously banned user?

@kevinmcconnell
Copy link
Copy Markdown
Collaborator Author

@TyIsI yes, this banning feature is per-IP, as well as blocking the user account. If someone moves to another IP address they could sign up again as a different user. Preventing that would require a way to differentiate between the same (banned) person signing up a fresh account from a different IP, vs an unrelated signup.

And agree, banning by IP can sometimes be quite a blunt tool. With shared IPs it's possible you would affect other people in the ban. But again, there's a limit to what you can control from within the app.

This feature is meant to be a pragmatic option that you can reach for if someone is acting in an abusive or antisocial way. It gets the malicious user out of the chat immediately, and the IP ban makes it more work for them to keep signing up repeatedly (which is likely to deter many users in practice). But it does have edge cases and workarounds.

We can always consider improvements to this, too. It doesn't have to be the final answer. But I think we do need a ban to be more than just disabling the user account for it to be effective.

Peyochanchan referenced this pull request in Peyochanchan/once-campfire Apr 13, 2026
Add IP-based user banning
Closes: #95
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants