Use separate keys for invisble captcha
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 22 Aug 2017 14:16:36 +0000 (16:16 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 22 Aug 2017 14:16:36 +0000 (16:16 +0200)
Technically keys for invisible captcha seem to work for stock v2,
but according to the documentation they should not. Better play safe
here.

Closes #2242

com.woltlab.wcf/option.xml
com.woltlab.wcf/templates/recaptcha.tpl
wcfsetup/install/files/acp/templates/recaptcha.tpl
wcfsetup/install/files/lib/system/recaptcha/RecaptchaHandlerV2.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 9c49adafa55762422fa32708f231516e7b7d1e67..325202450ac6b00fb0276f46611214d600ecd81d 100644 (file)
@@ -769,6 +769,18 @@ private:wcf.acp.option.exception_privacy.private</selectoptions>
                                <validationpattern>^[^/]*$</validationpattern>
                                <showorder>2</showorder>
                        </option>
+                       <option name="recaptcha_publickey_invisible">
+                               <categoryname>security.antispam.recaptcha</categoryname>
+                               <optiontype>text</optiontype>
+                               <validationpattern>^[^/]*$</validationpattern>
+                               <showorder>3</showorder>
+                       </option>
+                       <option name="recaptcha_privatekey_invisible">
+                               <categoryname>security.antispam.recaptcha</categoryname>
+                               <optiontype>text</optiontype>
+                               <validationpattern>^[^/]*$</validationpattern>
+                               <showorder>4</showorder>
+                       </option>
                        <!-- /security.antispam.recaptcha -->
                        
                        <!-- general.system.date -->
index 1b5e9e8e4618a1090d8ca6c4e9f1fbc420f8c865..ce0a66293ee892b5920090407d8bfdd65f2afb49 100644 (file)
@@ -95,7 +95,7 @@
                </dl>
        </section>
        {else}
-               {if $supportsAsyncCaptcha|isset && $supportsAsyncCaptcha}
+               {if $supportsAsyncCaptcha|isset && $supportsAsyncCaptcha && RECAPTCHA_PUBLICKEY_INVISIBLE && RECAPTCHA_PRIVATEKEY_INVISIBLE}
                <section class="section">
                        <h2 class="sectionTitle">{lang}wcf.recaptcha.title{/lang}</h2>
                        {assign var="recaptchaBucketID" value=true|microtime|sha1}
                                                <div style="width: 302px; height: 473px;">
                                                        <div style="width: 302px; height: 422px; position: relative;">
                                                                <div style="width: 302px; height: 422px; position: relative;">
-                                                                       <iframe src="https://www.google.com/recaptcha/api/fallback?k={RECAPTCHA_PUBLICKEY|encodeJS}" frameborder="0" scrolling="no" style="width: 302px; height:422px; border-style: none;"></iframe>
+                                                                       <iframe src="https://www.google.com/recaptcha/api/fallback?k={RECAPTCHA_PUBLICKEY_INVISIBLE|encodeJS}" frameborder="0" scrolling="no" style="width: 302px; height:422px; border-style: none;"></iframe>
                                                                </div>
                                                                <div style="width: 300px; height: 60px; position: relative; border-style: none; bottom: 12px; left: 0; margin: 0px; padding: 0px; right: 25px; background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px;">
                                                                        <textarea name="g-recaptcha-response" class="g-recaptcha-response" style="width: 290px; height: 50px; border: 1px solid #c1c1c1; margin: 5px; padding: 0px; resize: none;"></textarea>
                                                                
                                                                var promise = new Promise(function (resolve, reject) {
                                                                        WCF.recaptcha.mapping['recaptchaBucket{$recaptchaBucketID}'] = grecaptcha.render(bucket, {
-                                                                               sitekey: '{RECAPTCHA_PUBLICKEY|encodeJS}',
+                                                                               sitekey: '{RECAPTCHA_PUBLICKEY_INVISIBLE|encodeJS}',
                                                                                size: 'invisible',
                                                                                badge: 'inline',
                                                                                callback: resolve
index 1b5e9e8e4618a1090d8ca6c4e9f1fbc420f8c865..ce0a66293ee892b5920090407d8bfdd65f2afb49 100644 (file)
@@ -95,7 +95,7 @@
                </dl>
        </section>
        {else}
-               {if $supportsAsyncCaptcha|isset && $supportsAsyncCaptcha}
+               {if $supportsAsyncCaptcha|isset && $supportsAsyncCaptcha && RECAPTCHA_PUBLICKEY_INVISIBLE && RECAPTCHA_PRIVATEKEY_INVISIBLE}
                <section class="section">
                        <h2 class="sectionTitle">{lang}wcf.recaptcha.title{/lang}</h2>
                        {assign var="recaptchaBucketID" value=true|microtime|sha1}
                                                <div style="width: 302px; height: 473px;">
                                                        <div style="width: 302px; height: 422px; position: relative;">
                                                                <div style="width: 302px; height: 422px; position: relative;">
-                                                                       <iframe src="https://www.google.com/recaptcha/api/fallback?k={RECAPTCHA_PUBLICKEY|encodeJS}" frameborder="0" scrolling="no" style="width: 302px; height:422px; border-style: none;"></iframe>
+                                                                       <iframe src="https://www.google.com/recaptcha/api/fallback?k={RECAPTCHA_PUBLICKEY_INVISIBLE|encodeJS}" frameborder="0" scrolling="no" style="width: 302px; height:422px; border-style: none;"></iframe>
                                                                </div>
                                                                <div style="width: 300px; height: 60px; position: relative; border-style: none; bottom: 12px; left: 0; margin: 0px; padding: 0px; right: 25px; background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px;">
                                                                        <textarea name="g-recaptcha-response" class="g-recaptcha-response" style="width: 290px; height: 50px; border: 1px solid #c1c1c1; margin: 5px; padding: 0px; resize: none;"></textarea>
                                                                
                                                                var promise = new Promise(function (resolve, reject) {
                                                                        WCF.recaptcha.mapping['recaptchaBucket{$recaptchaBucketID}'] = grecaptcha.render(bucket, {
-                                                                               sitekey: '{RECAPTCHA_PUBLICKEY|encodeJS}',
+                                                                               sitekey: '{RECAPTCHA_PUBLICKEY_INVISIBLE|encodeJS}',
                                                                                size: 'invisible',
                                                                                badge: 'inline',
                                                                                callback: resolve
index e5e46be79349f838655f6b3369f0c03659f7f7ea..c5c3c974758fe46c05d79c7a205a2eba6d676f37 100644 (file)
@@ -32,7 +32,7 @@ class RecaptchaHandlerV2 extends SingletonFactory {
                        $key = RECAPTCHA_PRIVATEKEY;
                }
                else if ($type === 'invisible') {
-                       $key = RECAPTCHA_PRIVATEKEY;
+                       $key = RECAPTCHA_PRIVATEKEY_INVISIBLE;
                }
                else {
                        throw new \InvalidArgumentException('$type must be either v2 or invisible.');
index 894dba3a6aa17c401f98374a853397c8d394fa38..66c89926503852ef5727bf62647dc98efaa56f5d 100644 (file)
                <item name="wcf.acp.option.enable_woltlab_news"><![CDATA[WoltLab-Nachrichten anzeigen]]></item>
                <item name="wcf.acp.option.enable_woltlab_news.description"><![CDATA[Aktiviert die Anzeige aktueller WoltLab-Nachrichten auf der Startseite der Administrationsoberfläche.]]></item>
                <item name="wcf.acp.option.category.security.antispam.recaptcha"><![CDATA[reCAPTCHA]]></item>
-               <item name="wcf.acp.option.recaptcha_publickey"><![CDATA[Websiteschlüssel]]></item>
+               <item name="wcf.acp.option.recaptcha_publickey"><![CDATA[Websiteschlüssel (reCAPTCHA, Version 2)]]></item>
                <item name="wcf.acp.option.recaptcha_publickey.description"><![CDATA[Einen eigenen Websiteschlüssel für die Nutzung der reCAPTCHA-Funktion {if LANGUAGE_USE_INFORMAL_VARIANT}kannst du{else}können Sie{/if} auf der Website von <a href="https://www.google.com/recaptcha/admin" class="externalURL">reCAPTCHA</a> beantragen.]]></item>
-               <item name="wcf.acp.option.recaptcha_privatekey"><![CDATA[Geheimer Schlüssel]]></item>
+               <item name="wcf.acp.option.recaptcha_privatekey"><![CDATA[Geheimer Schlüssel (reCAPTCHA, Version 2)]]></item>
+               <item name="wcf.acp.option.recaptcha_publickey_invisible"><![CDATA[Websiteschlüssel (Unsichtbares reCAPTCHA)]]></item>
+               <item name="wcf.acp.option.recaptcha_publickey_invisible.description"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Trage{else}Tragen Sie{/if} hier <b>zusätzlich</b> zu den obigen Schlüsseln Schlüssel für das unsichtbare reCAPTCHA ein, wenn {if LANGUAGE_USE_INFORMAL_VARIANT}du{else}Sie{/if}diese Variante nutzen {if LANGUAGE_USE_INFORMAL_VARIANT}möchtest{else}möchten{/if}.]]></item>
+               <item name="wcf.acp.option.recaptcha_privatekey_invisible"><![CDATA[Geheimer Schlüssel (Unsichtbares reCAPTCHA)]]></item>
                <item name="wcf.acp.option.category.message.attachment"><![CDATA[Dateianhänge]]></item>
                <item name="wcf.acp.option.attachment_enable_thumbnails"><![CDATA[Vorschaugrafiken von hochgeladenen Bilder erzeugen]]></item>
                <item name="wcf.acp.option.attachment_retain_dimensions"><![CDATA[Bildformat beim Erzeugen von Vorschaugrafiken beibehalten]]></item>
index bdbd86b1dbae052c6b99cf727355c94fab13b9d0..8343d50edf48957d37455afb8da49cec7ce3a2a7 100644 (file)
                <item name="wcf.acp.option.enable_woltlab_news"><![CDATA[Display WoltLab news]]></item>
                <item name="wcf.acp.option.enable_woltlab_news.description"><![CDATA[Displays the current WoltLab News on the Administration Control Panel’s index page.]]></item>
                <item name="wcf.acp.option.category.security.antispam.recaptcha"><![CDATA[reCAPTCHA]]></item>
-               <item name="wcf.acp.option.recaptcha_publickey"><![CDATA[Public API Key]]></item>
+               <item name="wcf.acp.option.recaptcha_publickey"><![CDATA[Public API Key (reCAPTCHA v2)]]></item>
                <item name="wcf.acp.option.recaptcha_publickey.description"><![CDATA[You can request your own API-Key for using reCAPTCHA on the <a href="https://www.google.com/recaptcha/admin" class="externalURL">reCAPTCHA website</a>.]]></item>
-               <item name="wcf.acp.option.recaptcha_privatekey"><![CDATA[Private API Key]]></item>
+               <item name="wcf.acp.option.recaptcha_privatekey"><![CDATA[Private API Key (reCAPTCHA v2)]]></item>
+               <item name="wcf.acp.option.recaptcha_publickey_invisible"><![CDATA[Public API Key (Invisible reCAPTCHA)]]></item>
+               <item name="wcf.acp.option.recaptcha_publickey_invisible.description"><![CDATA[Enter the keys <b>in addition</b> to the keys above if you want to use the invisible variant of reCAPTCHA.]]></item>
+               <item name="wcf.acp.option.recaptcha_privatekey_invisible"><![CDATA[Private API Key (Invisible reCAPTCHA)]]></item>
                <item name="wcf.acp.option.category.message.attachment"><![CDATA[Attachments]]></item>
                <item name="wcf.acp.option.attachment_enable_thumbnails"><![CDATA[Create thumbnails for attachment images]]></item>
                <item name="wcf.acp.option.attachment_retain_dimensions"><![CDATA[Retain thumbnail dimensions]]></item>