Skip to content

Commit d0eeee5

Browse files
docs(tls): Update docs for tls authentication
1 parent aa23418 commit d0eeee5

File tree

5 files changed

+99
-18
lines changed

5 files changed

+99
-18
lines changed

docs/DEVELOPER.md

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,41 @@ Activate the CrowdSec plugin
148148

149149
##### End-to-end tests
150150

151+
We are using a Jest/Playwright Node.js stack to launch a suite of end-to-end tests.
152+
153+
**Please note** that those tests modify local configurations and log content on the fly.
154+
155+
As we use a TLS ready CrowdSec container, you have first to copy some certificates and key:
156+
157+
```bash
158+
cd wp-sources
159+
cp -r .ddev/custom_files/crowdsec/cfssl/* wp-content/plugins/crowdsec/tls
160+
```
161+
162+
Then, ensure that `run-tests.sh` and `test-init.sh` files are executable.
163+
151164
```
152165
cd wp-sources/my-own-module/crowdsec-bouncer/tests/e2e-ddev/__scripts__
153166
```
154-
Ensure that `run-tests.sh` and `test-init.sh` files are executable. Run `chmod +x run-tests.sh test-init.sh` if not.
167+
Run `chmod +x run-tests.sh test-init.sh` if not.
168+
169+
Then you can use the `run-test.sh` script to run the tests:
170+
171+
- the first parameter specifies if you want to run the test on your machine (`host`) or in the
172+
docker containers (`docker`). You can also use `ci` if you want to have the same behavior as in GitHub action.
173+
- the second parameter list the test files you want to execute. If empty, all the test suite will be launched.
174+
175+
In other words, you can test by running:
176+
177+
`./run-tests.sh [context] [files]` where `[context]` can be `ci`, `docker` or `host` and files is the list of file to
178+
test (all files if empty);
179+
180+
For example:
181+
```
182+
./run-tests.sh host "./2-live-mode-remediations.js"
183+
```
155184

185+
**N.B**
156186

157187
Before testing with the `docker` or `ci` parameter, you have to install all the required dependencies
158188
in the playwright container with this command :
@@ -166,15 +196,7 @@ yarn --cwd ./tests/e2e-ddev --force
166196
yarn global add cross-env
167197
```
168198

169-
Finally, you can test by running:
170199

171-
`./run-tests.sh [context] [files]` where `[context]` can be `ci`, `docker` or `host` and files is the list of file to
172-
test (all files if empty);
173-
174-
For example:
175-
```
176-
./run-tests.sh host "./2-live-mode-remediations.js"
177-
```
178200

179201
#### Update composer dependencies
180202

@@ -204,7 +226,7 @@ ddev composer update --no-dev --prefer-dist --optimize-autoloader --working-dir
204226

205227
This guide exposes you the main features of the plugin.
206228

207-
Before all, please retrieve your host IP (a.k.a. <YOUR_HOST_IP>)with the command:
229+
Before all, please retrieve your host IP (a.k.a. <YOUR_HOST_IP>) with the command:
208230

209231
`ddev find-ip`
210232

@@ -264,16 +286,18 @@ ddev exec -s exec crowdsec cscli decisions add --ip <YOUR_HOST_IP> --duration 15
264286

265287
* Unless you manage to solve the captcha, you'll not be able to access the website.
266288

267-
> Note: when you resolve the captcha in your browser, the associated PHP session is considered as sure.
268-
> If you remove the captcha decision with `cscli`, then you add a new captcha decision for your IP, you'll not be prompted for the current PHP session. To view the captcha page, You can force using a new PHP session opening the front page with incognito mode.
289+
> Note: when you resolve the captcha in your browser, the result is stored in cache.
290+
> If you remove the captcha decision with `cscli`, then you add a new captcha decision for your IP, you'll not be
291+
> prompted until you clear the cache or the lifetime for captcha decision has been reached.
269292
270293
### Stream mode, for the high traffic websites
271294

272295
With live mode, as you tried it just before, each time a user arrives to the website for the first time, a call is made to Local API. If the traffic on your website is high, the bouncer will call Local API very often.
273296

274297
To avoid this, Local API offers a "stream" mode. The decisions list is updated at a predefined frequency and kept in cache. Let's try it!
275298

276-
> This bouncer uses the WordPress cron system. For demo purposes, we encourage you to install the WP-Control plugin, a plugin to view and control each Wordpress Cron task jobs.
299+
> This bouncer uses the WordPress cron system. For demo purposes, we encourage you to install the WP-Control plugin,
300+
> a plugin to view and control each WordPress Cron task jobs.
277301
278302
First, clear the previous decisions:
279303

@@ -366,13 +390,13 @@ Before publishing a new release, there are some manual steps to take:
366390

367391
- Change the version number and stable tag in the `crowdsec.php` file
368392
- Change the stable tag in the `readme.txt` file
369-
- Change the version number in the `inc/constants.php` file
393+
- Change the version number in the `inc/Constants.php` file
370394
- Update the `CHANGELOG.md` file
371395

372396
Then, you have to [run the action manually from the GitHub repository](https://github.com/crowdsecurity/cs-wordpress-bouncer/actions/workflows/release.yml)
373397

374398

375-
Alternatively, you could use the [Github CLI](https://github.com/cli/cli):
399+
Alternatively, you could use the [GitHub CLI](https://github.com/cli/cli):
376400
- create a draft release:
377401
```
378402
gh workflow run release.yml -f tag_name=vx.y.z -f draft=true
@@ -386,7 +410,7 @@ gh workflow run release.yml -f tag_name=vx.y.z -f prerelease=true
386410
gh workflow run release.yml -f tag_name=vx.y.z
387411
```
388412

389-
Note that the Github action will fail if the tag `tag_name` already exits.
413+
Note that the GitHub action will fail if the tag `tag_name` already exits.
390414

391415

392416

docs/USER_GUIDE.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ These configurations are divided in three main parts : `CrowdSec`, `Theme custom
6868
In the `CrowdSec` part, you will set your connection details and refine bouncing according to your needs. You will
6969
also be able to test your settings.
7070

71-
![Connection details](images/screenshots/config-connection.jpg)
71+
![Connection details](images/screenshots/config-connection-details.jpg)
7272

7373
***
7474

@@ -79,10 +79,65 @@ Url to join your CrowdSec Local API.
7979

8080
***
8181

82+
`Connection details → Authentication type`
83+
84+
Choose between `Bouncer API key` and `TLS certificates` (pki) authentication.
85+
86+
TLS authentication is only available if you use CrowdSec agent with a version superior to 1.4.0.
87+
Please see [CrowdSec documentation](https://docs.crowdsec.net/docs/local_api/tls_auth/).
88+
89+
***
90+
8291
`Connection details → Bouncer API key`
8392

8493
Key generated by the cscli command.
8594

95+
Only if you chose `Bouncer API key` as authentication type.
96+
97+
***
98+
99+
`Connection details → Path to the bouncer certificate`
100+
101+
Relative path to the `wp-content/plugins/crowdsec/tls` folder of your WordPress instance.
102+
103+
Example: `bouncer.pem`.
104+
105+
Only if you chose `TLS certificates` as authentication type.
106+
107+
***
108+
109+
`Connection details → Path to the bouncer key`
110+
111+
Relative path to the `wp-content/plugins/crowdsec/tls` folder of your WordPress instance.
112+
113+
Example: `bouncer-key.pem`.
114+
115+
Only if you chose `TLS certificates` as authentication type.
116+
117+
***
118+
119+
`Connection details → Verify peer`
120+
121+
This option determines whether request handler verifies the authenticity of the peer's certificate.
122+
123+
Only if you chose `TLS certificates` as authentication type.
124+
125+
When negotiating a TLS or SSL connection, the server sends a certificate indicating its identity.
126+
If `Verify peer` is checked, request handler verifies whether the certificate is authentic.
127+
This trust is based on a chain of digital signatures,
128+
rooted in certification authority (CA) certificate you supply using the `Path to the CA used to process for peer
129+
verification` setting below.
130+
131+
***
132+
133+
`Connection details → Path to the CA certificate used to process peer verification`
134+
135+
Relative path to the `wp-content/plugins/crowdsec/tls` folder of your WordPress instance.
136+
137+
Example: `ca-chain.pem`.
138+
139+
Only if you chose `TLS certificates` as authentication type.
140+
86141

87142
***
88143

@@ -93,6 +148,8 @@ By default, `file_get_contents` method is used to call Local API. This method re
93148
Here, you can choose to use `cURL` requests instead. Beware that in this case, you need to have php `cURL` extension
94149
installed and enabled on your system.
95150

151+
![Connection details](images/screenshots/config-bouncing.jpg)
152+
96153
***
97154

98155
`Bouncing → Bouncing level`
52.3 KB
Loading
60.7 KB
Loading

tests/e2e-ddev/__tests__/3-live-mode-more.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ describe(`Run in Live mode`, () => {
207207
);
208208

209209
// Good settings without curl
210-
await setToggle("crowdsec_use_curl", true);
210+
await setToggle("crowdsec_use_curl", false);
211211
await onAdminSaveSettings();
212212
await page.click("#crowdsec_action_test_connection #submit");
213213
await wait(2000);

0 commit comments

Comments
 (0)