reCAPTCHA custom form parameter names

321 views
Skip to first unread message

Davor Poldrugo

unread,
Jun 1, 2012, 7:20:09 AM6/1/12
to reca...@googlegroups.com
Is possible to customize reCAPTCHA form parameters (recaptcha_challenge_field and recaptcha_response_field) so that they are called differently?

Basically I want the form parameter recaptcha_challenge_field to be called captchaId,
and recaptcha_response_field to be called captchaUserResponse.

Now my request looks like this:

    POST /mysite/userSignup HTTP/1.1
    Host: localhost:80
    Connection: keep-alive
    Content-Length: 416
    Cache-Control: max-age=0
    Origin: http://localhost:80
    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.46 Safari/536.5
    Content-Type: application/x-www-form-urlencoded
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Referer: http://localhost:8080/mysite/signup/form.html
    Accept-Encoding: gzip,deflate,sdch
    Accept-Language: en-US,en;q=0.8,hr;q=0.6
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
    
    email:testUser%40gmail.com
    username:testUser
    password:test
    password2:test
    forename:Test
    surname:User
    recaptcha_challenge_field:<google generated challange>
    recaptcha_response_field:<user typed captcha answer>
    submit:Submit

But I want it to look like this:

    POST /mysite/userSignup HTTP/1.1
    Host: localhost:80
    Connection: keep-alive
    Content-Length: 416
    Cache-Control: max-age=0
    Origin: http://localhost:80
    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.46 Safari/536.5
    Content-Type: application/x-www-form-urlencoded
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Referer: http://localhost:8080/mysite/signup/form.html
    Accept-Encoding: gzip,deflate,sdch
    Accept-Language: en-US,en;q=0.8,hr;q=0.6
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
    
    email:testUser%40gmail.com
    username:testUser
    password:test
    password2:test
    forename:Test
    surname:User
    captchaId:<google generated challange>
    captchaUserResponse:<user typed captcha answer>
    submit:Submit

An elegant way would be to specify those form parameter names like this:

    <script>
       var RecaptchaOptions = {
          recaptcha_challenge_field_formparam_name : 'captchaId',
          recaptcha_response_field_formparam_name: 'captchaUserResponse'
       };
    </script>


If this isn't possible, what workaround do you suggest?

PS: link to the question on stackoverflow

بول

unread,
Jun 1, 2012, 7:34:31 AM6/1/12
to reca...@googlegroups.com
On Fri, Jun 1, 2012 at 12:20 PM, Davor Poldrugo <dpol...@gmail.com> wrote:
Is possible to customize reCAPTCHA form parameters (recaptcha_challenge_field and recaptcha_response_field) so that they are called differently?

Not in the way you suggest.

Why do you need them to be renamed?
 
If this isn't possible, what workaround do you suggest?

To use php as an example, rather than directly echoing the output of recaptcha_get_html($publickey) you first do a search/replace on the return value and echo the modified data.

--
PJH


Davor Poldrugo

unread,
Jun 1, 2012, 8:01:37 AM6/1/12
to reca...@googlegroups.com
Why do you need them to be renamed?
I want them renamed so I can abstract the captcha implementation...
When a request arrives on POST /mysite/userSignup, I don't want to bother with captcha implementation (reCaptcha, or something else in the future) - extracting the right parameters for the right captcha implementation, I want to unify those parameter names.

To use php as an example, rather than directly echoing the output of recaptcha_get_html($publickey) you first do a search/replace on the return value and echo the modified data.
recaptcha_get_html returns the following:

var RecaptchaState = {
    site : '6LfpttESAAAAAEEyUN7yfH5GtkKG8tsJh3-1WJpN',
    rtl : false,
    challenge : '03AHJ_Vutej1RP_FhSJQ5D4wmLmiwucABNxmH7KAK5dIPJVh5u1SbxjmRVDVz-q2q--JTnTThrYe65L6v-VSIQyPNL_WBp1OXVmMCdXTuf36uScNYvP9vXXTDe5wH69ZitxXKVB8FZtQnASDjrriJcmKebuARuC9k35w',
    is_incorrect : false,
    programming_error : '',
    error_message : '',
    server : 'http://www.google.com/recaptcha/api/',
    lang : 'en-US',
    timeout : 1800
};
document.write('<scr'+'ipt type="text/javascript" s'+'rc="' + RecaptchaState.server + 'js/recaptcha.js"></scr'+'ipt>');

So there is nothing to search and replace. The form parameter names are generated inside http://www.google.com/recaptcha/api/js/recaptcha.js


On Friday, June 1, 2012 1:34:31 PM UTC+2, Paul Herring wrote:

بول

unread,
Jun 1, 2012, 8:56:50 AM6/1/12
to reca...@googlegroups.com
On Fri, Jun 1, 2012 at 1:01 PM, Davor Poldrugo <dpol...@gmail.com> wrote:
So there is nothing to search and replace.

Oh bother - my assumption was wrong...
 
The form parameter names are generated inside http://www.google.com/recaptcha/api/js/recaptcha.js

Quickest hack, the, would be to host a local copy of that file with the required changes but you'd lose any updates to the file. More involved would be to perhaps once a day/week automatically download it and search/replace.

--
PJH


Reply all
Reply to author
Forward
0 new messages