Difference between revisions of "Recaptcha field"

From EPrints Documentation
Jump to: navigation, search
(Added ToC. Added API and Examples sections. Reorganised other sections.)
m
 
(6 intermediate revisions by the same user not shown)
Line 3: Line 3:
  
 
== Description ==
 
== Description ==
Please refer to the notes in <tt>EPRINTS_PATH/archives/ARCHIVEID/cfg/cfg.d/recaptcha.pl</tt>.
+
Allows a Captcha using [https://developers.google.com/recaptcha/docs/display Google's reCAPTCHAv2 service] to be added to a form to protect it from being spammed by bots.
  
If this files does not exist, copy <tt>EPRINTS_PATH/lib/defaultcfg/cfg.d/recaptcha.pl.example</tt>
+
Add the following configuration to a file called <code>cfg/cfg.d/recaptcha.pl</code> in your archive, if it does not already exist.
to the path above and edit it.
+
$c->{recaptcha}->{private_key} = "CHANGEME";
 +
$c->{recaptcha}->{public_key} = "CHANGEME";
  
This field uses the Google "reCAPTCHA" service (https://www.google.com/recaptcha/intro/) and
+
As this field uses the Google's reCAPTCHAv2 service and renders a Captcha, (a test that humans can easily pass, but robots shouldn't be able to), you will need to use a Google account to generate a private key and public key (also known by Google as a '''secret key''' and '''site key''' respectively) for the above configuration.  This can be done via Google's '''[https://www.google.com/recaptcha/admin/create Site Registration Tool]'''.  By sure to use '''Challenge (v2)''' option when registering.
renders a Captcha (a test that humans can easily pass, but robots shouldn't be able to).
+
 
 +
If you are setting up a Recaptcha field for protecting request copy forms, you will need to add the following configuration to a file in your archive's <code>cfg/cfg.d/</code> directory.
 +
$c->add_dataset_field( "request", {
 +
  name => "captcha",
 +
  replace_core => 1,
 +
  type => "recaptcha",
 +
});
  
 
== Inheritance ==
 
== Inheritance ==
Line 16: Line 23:
 
*** [[Recaptcha field]]
 
*** [[Recaptcha field]]
  
== Properties ==
+
== Additional Properties ==
As for [[Id field]]s.
+
As for [[Id field#Additional_Phrases|Id fields]].
  
 
== Required Phrases ==
 
== Required Phrases ==
'''validate:recaptcha_mismatch''' - Phrase to display if reCAPTCHA submission errored in some way.
+
<tt>validate:recaptcha_mismatch</tt> - Phrase to display if reCAPTCHA submission errored in some way.
 +
 
 +
== Database ==
 +
Recaptcha fields are not stored in the database they are just so reCAPTCHA can be added to certain forms.  The result of the reCAPTCHA does not need to be stored.
  
 
== API ==
 
== API ==

Latest revision as of 08:32, 21 July 2024

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


Metadata Fields: Arclanguage - Base64 - Bigint - Boolean - Compound - Counter - Dataobjref - Date - Decimal - Email - Fields - Float - Id - Idci - Image - Int - Itemref - Keywords - Langid - Longtext - Longtext_counter - Multilang - Multipart - Name - Namedset - Pagerange - Recaptcha - Recaptcha3 - Relation - Search - Secret - Set - Storable - Subject - Subobject - Text - Time - Timestamp - Url - Uuid


Description

Allows a Captcha using Google's reCAPTCHAv2 service to be added to a form to protect it from being spammed by bots.

Add the following configuration to a file called cfg/cfg.d/recaptcha.pl in your archive, if it does not already exist.

$c->{recaptcha}->{private_key} = "CHANGEME";
$c->{recaptcha}->{public_key} = "CHANGEME";

As this field uses the Google's reCAPTCHAv2 service and renders a Captcha, (a test that humans can easily pass, but robots shouldn't be able to), you will need to use a Google account to generate a private key and public key (also known by Google as a secret key and site key respectively) for the above configuration. This can be done via Google's Site Registration Tool. By sure to use Challenge (v2) option when registering.

If you are setting up a Recaptcha field for protecting request copy forms, you will need to add the following configuration to a file in your archive's cfg/cfg.d/ directory.

$c->add_dataset_field( "request", {
  name => "captcha",
  replace_core => 1,
  type => "recaptcha",
});

Inheritance

Additional Properties

As for Id fields.

Required Phrases

validate:recaptcha_mismatch - Phrase to display if reCAPTCHA submission errored in some way.

Database

Recaptcha fields are not stored in the database they are just so reCAPTCHA can be added to certain forms. The result of the reCAPTCHA does not need to be stored.

API

See API page.

Examples

Most basic example.

{
    name => 'captcha',
    type => 'recaptcha',
}