]> sipb.mit.edu Git - ikiwiki.git/commitdiff
Expand banned_users; it can now include PageSpecs, which allows banning by IP address.
authorJoey Hess <joey@gnu.kitenet.net>
Tue, 8 Sep 2009 19:17:39 +0000 (15:17 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Tue, 8 Sep 2009 19:17:39 +0000 (15:17 -0400)
IkiWiki/CGI.pm
debian/changelog
doc/banned_users.mdwn
doc/todo/blocking_ip_ranges.mdwn

index af58d7cb56893a831d5ae798d5c5f16fc96b23fd..52cafade0f9f7f7ae155402464283e22c991a67d 100644 (file)
@@ -252,16 +252,30 @@ sub check_banned ($$) {
        my $q=shift;
        my $session=shift;
 
+       my $banned=0;
        my $name=$session->param("name");
-       if (defined $name) {
-               if (grep { $name eq $_ } @{$config{banned_users}}) {
-                       $session->delete();
-                       cgi_savesession($session);
-                       cgi_custom_failure(
-                               $q->header(-status => "403 Forbidden"),
-                               gettext("You are banned."));
+       if (defined $name && 
+           grep { $name eq $_ } @{$config{banned_users}}) {
+               $banned=1;
+       }
+
+       foreach my $b (@{$config{banned_users}}) {
+               if (pagespec_match("", $b,
+                       ip => $ENV{REMOTE_ADDR},
+                       name => defined $name ? $name : "",
+               )) {
+                       $banned=1;
+                       last;
                }
        }
+
+       if ($banned) {
+               $session->delete();
+               cgi_savesession($session);
+               cgi_custom_failure(
+                       $q->header(-status => "403 Forbidden"),
+                       gettext("You are banned."));
+       }
 }
 
 sub cgi_getsession ($) {
index 6109a70127a709b519d95e5c03bc5440c9f9f81e..86e8513f75702f222635333a24247b8868548bbb 100644 (file)
@@ -2,6 +2,8 @@ ikiwiki (3.14159265) UNRELEASED; urgency=low
 
   * Add French basewiki translation from the Debian French l10n team,
     including Philippe Batailler, Alexandre Dupas, and Steve Petruzzello.
+  * Expand banned_users; it can now include PageSpecs, which
+    allows banning by IP address.
 
  -- Joey Hess <joeyh@debian.org>  Wed, 02 Sep 2009 15:01:27 -0400
 
index d2bec90f0459d9016461293bb4c68fa8849f078c..c44f8c587fd12af58e0f0e0275e76d7123b2b57b 100644 (file)
@@ -1,4 +1,10 @@
-Banned users can be configured in the setup file.
+Banned users can be configured in the setup file via the `banned_users`
+setting. This is a list of user names, or [[PageSpecs|ikiwiki/PageSpec]]
+to ban. Using a PageSpec is useful to block an IP address.
+
+For example:
+
+       banned_users => ['evilspammer', 'ip(192.168.1.1)'],
 
 If a banned user attempts to use the ikiwiki CGI, they will receive a 403
 Forbidden webpage indicating they are banned.
index 95026eef126a4b64c932ae3274d751b7359fe7be..ac2344ece877aa565c696fbb69c817f48ae96747 100644 (file)
@@ -2,3 +2,6 @@ Admins need the ability to block IP ranges. They can already ban users.
 
 See [[fileupload]] for a propsal that grew to encompass the potential to do
 this.
+
+[[done]] (well, there is no pagespec for IP ranges yet, but we can block
+individual IPs)