Skip to content

Commit 074392a

Browse files
author
Gregor Pollak
committed
Update Readme and update JS code example
1 parent 2d6ee87 commit 074392a

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

Config/Comment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function getCommentText($elementValue): string
3636
3737
let secretKey = \'-the-value-from-above-\'
3838
let date = new Date(). getTime()
39-
let hash = CryptoJS.MD5(secretKey + \'-\' + date)
39+
let hash = CryptoJS.MD5(secretKey + \'-\' + date).toString(CryptoJS.enc.Hex)
4040
cy.setCookie(\'' . Provider::COOKIE_KEY . '\', hash);
4141
</pre></code>
4242
</div>';

README.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,46 @@
11
# RocketWeb Captcha Bypass
22
The extension disables Google reCAPTCHA by providing a simple hashed value thru a cookie
33

4-
More details to come soon!
4+
## Installation
5+
Using composer:
6+
```
7+
composer2 require rocketweb/magento-captcha-bypass
8+
```
9+
10+
## Setup
11+
Once installed, you need to configure the extension in
12+
**Stores -> Settings -> Configuration** then open **Security (tab)
13+
-> Google reCAPTCHA Storefront -> Bypass Storefront ReCaptcha** and set a unique
14+
random string for Secret Key field:
15+
![Screenshot from Admin displaying Secret Key field](https://user-images.githubusercontent.com/9031414/250605077-4fc259d6-3f7a-4001-8154-4ca4893d7eb8.png)
16+
17+
## Usage
18+
When creating a Cypress Test, first you need to add ``CryptoJs`` library (or something similar that supports MD5):
19+
```
20+
npm install crypto-js
21+
```
22+
If all your packages are dev-dependencies, install this also as dependency:
23+
```
24+
npm install crypto-js --save-dev
25+
```
26+
Then include the crypto-js into at the top of the Cypress Test file:
27+
```
28+
# ... (other import lines) ...
29+
import CryptoJS from 'crypto-js';
30+
```
31+
The final step is setting the Cookie needed to activate the Recaptcha Bypass
32+
inside the `it()` before any `cy.visit(...)` is called:
33+
```
34+
it(['Can create an account', () => {
35+
let secretKey = '-Secret-Key-value-from-above-'
36+
let date = new Date(). getTime()
37+
let hash = CryptoJS.MD5(secretKey + '-' + date).toString(CryptoJS.enc.Hex)
38+
cy.setCookie('__rbp', hash);
39+
40+
cy.visit(...)
41+
...
42+
})
43+
```
44+
45+
This will add a cookie with specific hash that is than recognized by Magento code
46+
which disabled ReCaptcha on the page (if it's enabled that is).

etc/adminhtml/system.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<field id="secret_key" translate="label" sortOrder="100" type="text" showInDefault="1"
99
showInWebsite="1" showInStore="0">
1010
<comment><model>RocketWeb\CaptchaBypass\Config\Comment</model></comment>
11+
<label>Security Key</label>
1112
</field>
1213
</group>
1314
</section>

0 commit comments

Comments
 (0)