]> sipb.mit.edu Git - ikiwiki.git/blobdiff - doc/todo/require_CAPTCHA_to_edit.mdwn
response, analysis of validation problem
[ikiwiki.git] / doc / todo / require_CAPTCHA_to_edit.mdwn
index 0e32afc65dd68ddc75340c1eeade1ddd7ca6d0c2..64f0a38d8179fd4c497ceccd0b109042954260c1 100644 (file)
@@ -14,6 +14,15 @@ I imagine a plugin that modifies the login screen to use <http://recaptcha.net/>
 >> Something like the moinmoin global <http://master.moinmo.in/BadContent>
 >> list?
 
+>>> OpenID can be thought of as pushing the problem of determining if
+>>> someone is a human or a spambot back from the openid consumer to the
+>>> openid provider. So, providers that make it possible for spambots to
+>>> use their openids, or that are even set up explicitly for use in
+>>> spamming, would be the ones to block. Or, providers that are known to
+>>> use very good screening for humans would be the ones to allow.
+>>> (Openid delegation makes it a bit harder than just looking at the
+>>> openid url though.) --[[Joey]]
+
 Okie - I have a first pass of this.  There are still some issues.
 
 Currently the code verifies the CAPTCHA.  If you get it right then you're fine.
@@ -30,7 +39,33 @@ A second issue is that the OpenID login system resets the 'required' flags
 of all the other fields, so using OpenID will cause the CAPTCHA to be
 ignored.
 
-> This is still a todo.
+> This is still not fixed.  I would have thought the following patch would
+> have fixed this second issue, but it doesn't.
+
+--- a/IkiWiki/Plugin/openid.pm
++++ b/IkiWiki/Plugin/openid.pm
+@@ -61,6 +61,7 @@ sub formbuilder_setup (@) { #{{{
+                        # Skip all other required fields in this case.
+                        foreach my $field ($form->field) {
+                                next if $field eq "openid_url";
++                               next if $field eq "recaptcha";
+                                $form->field(name => $field, required => 0,
+                                        validate => '/.*/');
+                        }
+
+>> What seems to be happing here is that the openid plugin defines a
+>> validate hook for openid_url that calls validate(). validate() in turn
+>> redirects the user to the openid server for validation, and exits. If
+>> the openid plugins' validate hook is called before your recaptcha
+>> validator, your code never gets a chance to run. I don't know how to
+>> control the other that FormBuilder validates fields, but the only fix I
+>> can see is to somehow influence that order. 
+>>
+>> Hmm, maybe you need to move your own validation code out of the validate
+>> hook. Instead, just validate the captcha in the formbuilder_setup hook.
+>> The problem with this approach is that if validation fails, you can't
+>> just flag it as invalid and let formbuilder handle that. Instead, you'd
+>> have to hack something in to redisplay the captcha by hand. --[[Joey]]
 
 Instructions
 =====