Skip to content

Commit 5413b73

Browse files
authored
Merge pull request #50 from delyriand/feature/altcha-1.x
2 parents 84c998a + 0d06539 commit 5413b73

26 files changed

+389
-32
lines changed

.github/workflows/recipe.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
php: ['8.1', '8.2', '8.3']
18-
sylius: ["~1.12.0", "~1.13.0", "1.14.0"]
17+
php: ['8.2', '8.3']
18+
sylius: ["~1.13.0", "1.14.0"]
1919

2020
steps:
2121
- name: Setup PHP

.github/workflows/security.yaml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
php: ['8.1', '8.2', '8.3']
16+
php: ['8.2', '8.3']
1717

1818
steps:
1919
- uses: actions/checkout@v3
@@ -49,5 +49,28 @@ jobs:
4949
- name: Install PHP dependencies
5050
run: composer update --prefer-dist
5151

52-
- uses: symfonycorp/security-checker-action@v4
52+
- uses: symfonycorp/security-checker-action@v5
53+
with:
54+
disable-exit-code: 1
55+
id: security-check
5356

57+
- name: Filter vulnerabilities
58+
run: |
59+
echo '${{ steps.security-check.outputs.vulns }}' \
60+
| jq 'with_entries(
61+
.value.advisories |= map(
62+
select(.cve != "CVE-2025-31481" and .cve != "CVE-2025-31485")
63+
)
64+
)' \
65+
> filtered.json
66+
67+
cat filtered.json
68+
69+
# Compter les vulnérabilités restantes
70+
remaining=$(jq '[.[] | .advisories[]] | length' filtered.json)
71+
if [ "$remaining" -gt 0 ]; then
72+
echo "❌ Security issues found ($remaining remaining)"
73+
exit 1
74+
else
75+
echo "✅ No relevant security issues"
76+
fi

.github/workflows/tests.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
php: ['8.1', '8.2', '8.3']
17+
php: ['8.2', '8.3']
18+
node: ['20']
1819

1920
env:
2021
SYMFONY_ARGS: --no-tls
@@ -25,7 +26,7 @@ jobs:
2526
- uses: actions/checkout@v2
2627
- uses: actions/setup-node@v2
2728
with:
28-
node-version: '14'
29+
node-version: ${{ matrix.node }}
2930
- name: Setup PHP
3031
uses: shivammathur/setup-php@v2
3132
with:

DEVELOPMENT.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,14 @@ Be sure you have the Symfony binary on your machine.
1313
```
1414
curl -sS https://get.symfony.com/cli/installer | bash
1515
```
16+
17+
# Build assets
18+
19+
Install dependencies
20+
`yarn install`
21+
22+
While developing your JS, you can use :
23+
`yarn run watch`
24+
25+
Then generate the final files and push it :
26+
`yarn run build`

README.md

Lines changed: 82 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Banner of Sylius Anti Spam plugin](docs/images/banner.jpg)](https://monsieurbiz.com/agence-web-experte-sylius)
1+
[![Banner of Sylius Anti Spam plugin](docs/images/antispam-banner.jpg)](https://monsieurbiz.com/agence-web-experte-sylius)
22

33
<h1 align="center">Anti Spam</h1>
44

@@ -11,11 +11,10 @@ This plugins adds captcha and allows you to manage your spams.
1111

1212
## Compatibility
1313

14-
| Sylius Version | PHP Version |
15-
|----------------|-----------------|
16-
| 1.12 | 8.1 - 8.2 - 8.3 |
17-
| 1.13 | 8.1 - 8.2 - 8.3 |
18-
| 1.14 | 8.1 - 8.2 - 8.3 |
14+
| Sylius Version | PHP Version |
15+
|----------------|-------------|
16+
| 1.13 | 8.2 - 8.3 |
17+
| 1.14 | 8.2 - 8.3 |
1918

2019
## Installation
2120

@@ -25,17 +24,87 @@ If you want to use our recipes, you can configure your composer.json by running:
2524
composer config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]'
2625
```
2726

28-
⚙️ To Be Defined.
27+
```bash
28+
composer require monsieurbiz/sylius-anti-spam-plugin
29+
```
30+
31+
Run post installation command
32+
```bash
33+
cp -r vendor/monsieurbiz/sylius-anti-spam-plugin/dist/config config/
34+
```
35+
36+
<details>
37+
<summary>For the installation without flex, follow these additional steps</summary>
38+
<p>
39+
40+
Change your `config/bundles.php` file to add the line for the plugin :
41+
42+
```php
43+
<?php
44+
45+
return [
46+
//..
47+
MonsieurBiz\SyliusRichEditorPlugin\MonsieurBizSyliusAntiSpamPlugin::class => ['all' => true],
48+
];
49+
```
50+
51+
Then create the config file in `config/packages/monsieurbiz_sylius_anti_spam_plugin.yaml` :
52+
53+
```yaml
54+
imports:
55+
- { resource: "@MonsieurBizSyliusAntiSpamPlugin/Resources/config/config.yaml" }
56+
57+
services:
58+
# Add the "monsieurbiz_anti_spam.quarantineable" tag on the quarantineable entity (not autoconfigure the entity…)
59+
App\Entity\Customer\Customer:
60+
tags: ['monsieurbiz_anti_spam.quarantineable']
61+
```
62+
63+
Finally import the routes in `config/routes/monsieurbiz_sylius_anti_spam_plugin.yaml` :
64+
65+
```yaml
66+
monsieurbiz_sylius_anti_spam_admin:
67+
resource: "@MonsieurBizSyliusAntiSpamPlugin/Resources/config/routes/admin.yaml"
68+
prefix: /%sylius_admin.path_name%
69+
```
70+
</p>
71+
</details>
72+
73+
**Update customer entity**
74+
75+
Your `Customer` entity should implement `MonsieurBiz\SyliusAntiSpamPlugin\Entity\QuarantineItemAwareInterface` and use the `MonsieurBiz\SyliusAntiSpamPlugin\Entity\QuarantineItemAwareTrait` trait.
76+
77+
```diff
78+
namespace App\Entity\Customer;
2979
30-
<!--
31-
1. Use the trait `\MonsieurBiz\SyliusAntiSpamPlugin\Entity\CustomerQuarantineItemAwareTrait` in your Customer entity.
80+
use Doctrine\ORM\Mapping as ORM;
81+
+ use MonsieurBiz\SyliusAntiSpamPlugin\Entity\QuarantineItemAwareInterface;
82+
+ use MonsieurBiz\SyliusAntiSpamPlugin\Entity\QuarantineItemAwareTrait;
83+
use Sylius\Component\Core\Model\Customer as BaseCustomer;
3284
33-
2. Update your env vars with your Recaptcha site key and secret :
85+
#[ORM\Entity]
86+
#[ORM\Table(name: 'sylius_customer')]
87+
- class Customer extends BaseCustomer
88+
+ class Customer extends BaseCustomer implements QuarantineItemAwareInterface
89+
{
90+
+ use QuarantineItemAwareTrait
91+
}
92+
```
93+
94+
**Update your database schema**
95+
96+
Update your database schema with the plugin migrations:
97+
98+
```bash
99+
bin/console doctrine:migrations:migrate
100+
```
34101

35-
RECAPTCHA3_KEY=my_site_key
36-
RECAPTCHA3_SECRET=my_secret
102+
Generate the migration and update your database schema with the new customer entity field:
37103

38-
-->
104+
```bash
105+
bin/console doctrine:migrations:diff
106+
bin/console doctrine:migrations:migrate
107+
```
39108

40109
## Documentation
41110

UPGRADE-1.4.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# UPGRADE FROM `1.3.1` TO `1.4.0`
2+
3+
- Preconditions: PHP 8.2 support
4+
5+
- Copy config files from dist files, run the command:
6+
```
7+
cp -r vendor/monsieurbiz/sylius-anti-spam-plugin/dist/config config/
8+
```
9+
10+
- Create env vars:
11+
12+
```
13+
RECAPTCHA3_SCORE_THRESHOLD=0.5
14+
RECAPTCHA3_ENABLED=true
15+
ALTCHA_ENABLED=false
16+
ALTCHA_SECRET=CHANGEME
17+
```
18+
19+
- If you want to switch on Atcha, you can set `ALTCHA_ENABLED` to `true` and set the `ALTCHA_SECRET` to your secret key.
20+
21+
You can generate `ALTCHA_SECRET` with command `openssl rand -hex 32`
22+

assets/js/altcha-i18n.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import 'altcha/i18n/all';
2+
3+
globalThis.altchaI18n.set("fr-fr", {
4+
...globalThis.altchaI18n.get("fr-fr"),
5+
label: "Je ne suis pas un robot",
6+
});
7+
8+
globalThis.altchaI18n.set("fr-ca", {
9+
...globalThis.altchaI18n.get("fr-ca"),
10+
label: "Je ne suis pas un robot",
11+
});

assets/js/altcha.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import 'altcha';

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
"license": "MIT",
77
"require": {
88
"karser/karser-recaptcha3-bundle": "~0.1.16",
9-
"php": "^8.1",
10-
"sylius/sylius": ">=1.12 <2.0"
9+
"php": "^8.2",
10+
"sylius/sylius": ">=1.12 <2.0",
11+
"huluti/altcha-bundle": "^1.7.3"
1112
},
1213
"require-dev": {
1314
"friendsofphp/php-cs-fixer": "^3.16",
@@ -37,7 +38,7 @@
3738
},
3839
"extra": {
3940
"branch-alias": {
40-
"dev-master": "1.2-dev"
41+
"dev-master": "1.4-dev"
4142
},
4243
"symfony": {
4344
"docker": false,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
huluti_altcha:
2+
enable: '%env(bool:ALTCHA_ENABLED)%'
3+
hmacKey: '%env(ALTCHA_SECRET)%'
4+
floating: false
5+
use_stimulus: false
6+
altcha_js_path: /bundles/monsieurbizsyliusantispamplugin/js/altcha.js
7+
altcha_js_i18n_path: /bundles/monsieurbizsyliusantispamplugin/js/altcha-i18n.js
8+
9+
when@test:
10+
huluti_altcha:
11+
enable: false

0 commit comments

Comments
 (0)