NAME

Web::VWF::CAPTCHA - Check a Google reCAPTCHA answer

VERSION

Version 0.003.0

SYNOPSIS

my $captcha = Web::VWF::CAPTCHA->new(site_key => $site, secret_key => $secret, logger => $logger);
if($captcha->verify($info->param('g-recaptcha-response'), $ENV{'REMOTE_ADDR'})) {
	# a person
}

DESCRIPTION

Used by Web::VWF when a client has been shown the CAPTCHA page because it went over the rate limit. The keys are the recaptcha settings, see "CONFIGURATION" in Web::VWF.

METHODS

new

Takes site_key and secret_key, both required, and optionally a logger. Croaks when either key is missing.

API SPECIFICATION

INPUT

{
	site_key => { type => 'string' },
	secret_key => { type => 'string' },
	logger => { type => 'object', optional => 1 },
}

OUTPUT

{ type => 'object', isa => 'Web::VWF::CAPTCHA' }

verify

Asks Google whether the answer in $response_token is a good one, with a ten-second timeout. The second argument is the client's address, which Google is told and which is used in log messages. Anything that goes wrong, such as no token, no reply or a reply that cannot be read, is a failed verification and not an error.

API SPECIFICATION

INPUT

{ response_token => { type => 'string' }, remote_ip => { type => 'string', optional => 1 } }

OUTPUT

{ type => 'boolean' }	# 1 or 0

get_site_key

Returns the site key, which the CAPTCHA page puts in the form.

API SPECIFICATION

INPUT

{}

OUTPUT

{ type => 'string' }

AUTHOR

Nigel Horne, <njh at nigelhorne.com>

LICENCE AND COPYRIGHT

Copyright 2010-2026 Nigel Horne.

Usage is subject to the GPL2 licence terms. If you use it, please let me know.