Configuring reCAPTCHA v2 in Liferay Portal 6.2 EE

This article outlines how to configure reCAPTCHA version 2 in Liferay Portal 6.2.  Google is sunsetting reCAPTCHA v1 and as of March 2018 all v1 API calls will no longer work.

In response to this "End of Life" announcement, Liferay Portal 6.2 EE has been updated in LPS-55941 (LPE-16253) to include reCAPTCHA version 2.  Liferay Digital Enterprise already utilizes reCAPTCHA v2.

Resolution

To Utilize reCAPTCHA v2 in Liferay Portal 6.2 EE

  1. Install Fix Pack Portal-164 

  2. Stop the server and install fixpack portal-164 or higher.  Do not restart the server.

  3. If this is a production site, request a public and private key from Google for your specific domain by completing the instructions here: https://www.google.com/recaptcha/admin#list

  4. If this is a non-production environment, please visit Google’s reCAPTCHA support site to receive testing keys: https://developers.google.com/recaptcha/docs/faq

  5. Backup the existing portal-ext.properties file.

  6. Modify the portal-ext.properties to utilize the reCAPTCHA engine and the Google provided keys from step 2 or 3 (The captcha.engine.recaptcha.url.* properties are modified as part of the upgrade and are included below for reference.  These properties do not require user configuration).

       # Set the engine used to generate captchas. reCAPTCHA uses an external
    
       # service that must be configured independently but provides an audible
    
       # alternative which makes the captcha accessible to the visually impaired.
    
       # See https://www.google.com/recaptcha/admin/create for details.
    
       #
    
       captcha.engine.impl=com.liferay.portal.captcha.recaptcha.ReCaptchaImpl
    
       #
    
       # reCAPTCHA
    
       #
    
       captcha.engine.recaptcha.key.private={enter-your-private-key-here}
    
       captcha.engine.recaptcha.key.public={enter-your-public-key-here}
    
       captcha.engine.recaptcha.url.script=https://www.google.com/recaptcha/api.js
    
       captcha.engine.recaptcha.url.noscript=https://www.google.com/recaptcha/api/fallback?k=
    
       captcha.engine.recaptcha.url.verify=https://www.google.com/recaptcha/api/siteverify
    
  7. If captcha is desired for account creation, password resets, or message board activity, then modify the portal-ext to configure the desired captcha checks.  The default portal properties are listed below and should be modified to fit your needs:
       #
    
       # Set the maximum number of captcha checks per portlet session. Set this
    
       # value to 0 to always check. Set this value to a number less than 0 to
    
       # never check. Unauthenticated users will always be checked on every request
    
       # if captcha checks is enabled.
    
       #
    
       captcha.max.challenges=1
    
    
       #
    
       # Set whether or not to use captcha checks for the following actions.
    
       #
    
       captcha.check.portal.create_account=true
    
       captcha.check.portal.send_password=true
    
       captcha.check.portlet.message_boards.edit_category=false
    
       captcha.check.portlet.message_boards.edit_message=false
  8. Save the portal-ext file and restart the server.

  9. If this is the first time interacting with a reCAPTCHA request after installing the fixpack, then users must clear their browser cache to ensure the request functions properly.

Note: If it is necessary to uninstall Fix Pack Portal-164, then restoring the previous version of the portal-ext is also necessary.  The v1 reCAPTCHA keys will need to replace the v2 reCAPTCHA keys added in step 6 for reCAPTCHA requests to function properly.

这篇文章有帮助吗?
1 人中有 1 人觉得有帮助