Compare commits
1 Commits
3f667eede1
...
9cc4c7ac74
Author | SHA1 | Date | |
---|---|---|---|
9cc4c7ac74 |
15
readme.md
15
readme.md
@ -109,3 +109,18 @@ ex : `'redis:?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sen
|
|||||||
| `postgres` | Base de donnée postgres support du test et pour hydra | `5432` |
|
| `postgres` | Base de donnée postgres support du test et pour hydra | `5432` |
|
||||||
| `mariadb` | Base de donnée mariadb support du test | `3306` |
|
| `mariadb` | Base de donnée mariadb support du test | `3306` |
|
||||||
| `pgadmin` | pour administrer la base de donnée | `8085` |
|
| `pgadmin` | pour administrer la base de donnée | `8085` |
|
||||||
|
|
||||||
|
### Configuration d'Altcha
|
||||||
|
|
||||||
|
Altcha est activable/désactivable par un feature flag disponible à la route /flag/altcha (port 8082 par défaut).
|
||||||
|
La valeur de ce flag est stockée dans Redis (clé `altcha`) afin de pouvoir la modifier à la volée. Par sécurité, un fallback sur la variable d'environnement `ALTCHA_ENABLED` est effectué si la clé n'existe pas dans Redis.
|
||||||
|
|
||||||
|
Exemple de désactivation:
|
||||||
|
```shell
|
||||||
|
curl --request PUT \
|
||||||
|
--url http://localhost:8082/flag/altcha \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data '{
|
||||||
|
'\''flagValue'\'': false
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
@ -4,20 +4,29 @@ namespace App\Flag\Controller;
|
|||||||
|
|
||||||
use App\Flag\FlagEnum;
|
use App\Flag\FlagEnum;
|
||||||
use Predis\ClientInterface;
|
use Predis\ClientInterface;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
|
||||||
class FlagController extends AbstractController
|
class FlagController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/flag', name: 'flag_update', methods: ['PUT'])]
|
#[Route('/flag/{flagName}', name: 'flag_update', methods: ['PUT'])]
|
||||||
public function updateFlag(ClientInterface $redis, FlagEnum $flagName, bool $flagValue): Response
|
public function updateFlag(ClientInterface $redis, Request $request, string $flagName): Response
|
||||||
{
|
{
|
||||||
$redis->set($flagName->value, $flagValue);
|
try {
|
||||||
|
FlagEnum::from($flagName);
|
||||||
|
} catch (\ValueError $e) {
|
||||||
|
throw new \InvalidArgumentException('invalid flag name provided');
|
||||||
|
}
|
||||||
|
|
||||||
|
$flagValue = $request->query->getBoolean('flagValue');
|
||||||
|
|
||||||
|
$redis->set($flagName, $flagValue);
|
||||||
|
|
||||||
return new JsonResponse(
|
return new JsonResponse(
|
||||||
[\sprintf('flag %s has been %s.', $flagName->value, $flagValue ? 'enabled' : 'disabled')]
|
[\sprintf('flag %s has been %s.', $flagName, $flagValue ? 'enabled' : 'disabled')]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,6 @@ class LoginType extends AbstractType
|
|||||||
if ($this->flagAccessor->isFlagEnabled(FlagEnum::Altcha, $this->altchaEnabled)) {
|
if ($this->flagAccessor->isFlagEnabled(FlagEnum::Altcha, $this->altchaEnabled)) {
|
||||||
$builder->add('altcha', AltchaType::class, [
|
$builder->add('altcha', AltchaType::class, [
|
||||||
'label' => false,
|
'label' => false,
|
||||||
'translation_domain' => 'form',
|
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,29 @@
|
|||||||
.altcha label {
|
.altcha label {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
.panel-body {
|
||||||
|
max-width: 400px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<altcha-widget
|
<div>
|
||||||
challengejson={{challengeJson}}
|
<h3>
|
||||||
name={{form.vars.full_name}}
|
{% trans from 'form' %}altcha.widget.title{% endtrans %}
|
||||||
strings="{{translations}}"
|
</h3>
|
||||||
hidelogo
|
<div class="panel-body">
|
||||||
hidefooter
|
<altcha-widget
|
||||||
workers= {{ workers }}
|
challengejson={{challengeJson}}
|
||||||
delay={{ delay }}
|
name={{form.vars.full_name}}
|
||||||
{{ debug ? 'debug' : ''}}
|
strings="{{translations}}"
|
||||||
{{ mockError ? 'mockerror' : ''}}
|
hidelogo
|
||||||
></altcha-widget>
|
hidefooter
|
||||||
|
workers= {{ workers }}
|
||||||
|
delay={{ delay }}
|
||||||
|
{{ debug ? 'debug' : ''}}
|
||||||
|
{{ mockError ? 'mockerror' : ''}}
|
||||||
|
></altcha-widget>
|
||||||
|
<div class="alert alert-info">
|
||||||
|
{% trans from 'form' %}altcha.widget.info{% endtrans %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -6,23 +6,23 @@
|
|||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="login-wrapper">
|
<div class="login-wrapper">
|
||||||
<div class="login">
|
<div class="login">
|
||||||
{% if app.user %}
|
{% if app.user %}
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
You are logged in as {{ app.user.login }}
|
You are logged in as {{ app.user.login }}
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
<div class="lang">
|
|
||||||
{% for locale in locales %}
|
|
||||||
<a href="{{ path('locale_change', {'locale':locale }) }}" title="{{locale}}" aria-label="{{locale}}" class="flag"><img class="w-10" src="{{ asset('flags/'~ locale ~'.svg') }}"/></a>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
</div>
|
||||||
<h1 class="h3 mb-3 font-weight-normal">{% trans from 'view' %} sign_in {% endtrans %}</h1>
|
{% endif %}
|
||||||
{{form_start(loginForm)}}
|
<div class="lang">
|
||||||
{{form_widget(loginForm)}}
|
{% for locale in locales %}
|
||||||
|
<a href="{{ path('locale_change', {'locale':locale }) }}" title="{{locale}}" aria-label="{{locale}}" class="flag"><img class="w-10" src="{{ asset('flags/'~ locale ~'.svg') }}"/></a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
<h1 class="h3 mb-3 font-weight-normal">{% trans from 'view' %} sign_in {% endtrans %}</h1>
|
||||||
|
{{form_start(loginForm)}}
|
||||||
|
{{form_widget(loginForm)}}
|
||||||
<button class="btn btn-lg btn-primary" type="submit">
|
<button class="btn btn-lg btn-primary" type="submit">
|
||||||
{% trans from 'view' %} submit {% endtrans %}
|
{% trans from 'view' %} submit {% endtrans %}
|
||||||
</button>
|
</button>
|
||||||
{{form_end(loginForm)}}
|
{{form_end(loginForm)}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -19,31 +19,39 @@
|
|||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="4kfMq14" resname="altcha.validator.server_validation_error">
|
<trans-unit id="4kfMq14" resname="altcha.validator.server_validation_error">
|
||||||
<source>altcha.validator.server_validation_error</source>
|
<source>altcha.validator.server_validation_error</source>
|
||||||
<target xml:space="preserve">Verification failed. Try again later.</target>
|
<target>Verification failed. Try again later.</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="7mZdXx_" resname="altcha.widget.error">
|
<trans-unit id="7mZdXx_" resname="altcha.widget.error">
|
||||||
<source>altcha.widget.error</source>
|
<source>altcha.widget.error</source>
|
||||||
<target xml:space="preserve">Verification failed. Try again later.</target>
|
<target>Verification failed. Try again later.</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="Yg33QZt" resname="altcha.widget.expired">
|
<trans-unit id="Yg33QZt" resname="altcha.widget.expired">
|
||||||
<source>altcha.widget.expired</source>
|
<source>altcha.widget.expired</source>
|
||||||
<target xml:space="preserve">Verification expired. Try again.</target>
|
<target>Verification expired. Try again.</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="3y0.Bhb" resname="altcha.widget.label">
|
<trans-unit id="3y0.Bhb" resname="altcha.widget.label">
|
||||||
<source>altcha.widget.label</source>
|
<source>altcha.widget.label</source>
|
||||||
<target xml:space="preserve">I'm not a robot</target>
|
<target>I'm not a robot</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="QFBWtGD" resname="altcha.widget.verified">
|
<trans-unit id="QFBWtGD" resname="altcha.widget.verified">
|
||||||
<source>altcha.widget.verified</source>
|
<source>altcha.widget.verified</source>
|
||||||
<target xml:space="preserve">Verified</target>
|
<target>Verified</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="SfOrgtj" resname="altcha.widget.verifying">
|
<trans-unit id="SfOrgtj" resname="altcha.widget.verifying">
|
||||||
<source>altcha.widget.verifying</source>
|
<source>altcha.widget.verifying</source>
|
||||||
<target xml:space="preserve">Verifying...</target>
|
<target>Verifying...</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="9dhbPuz" resname="altcha.widget.waitalert">
|
<trans-unit id="9dhbPuz" resname="altcha.widget.waitalert">
|
||||||
<source>altcha.widget.waitalert</source>
|
<source>altcha.widget.waitalert</source>
|
||||||
<target xml:space="preserve">Verifying... please wait.</target>
|
<target>Verifying... please wait.</target>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="9k5hI.D" resname="altcha.widget.title">
|
||||||
|
<source>altcha.widget.title</source>
|
||||||
|
<target>Verification</target>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="vGcy2C3" resname="altcha.widget.info">
|
||||||
|
<source>altcha.widget.info</source>
|
||||||
|
<target>Please check the box above to validate that you are not a robot. If you encounter any problem while doing this, please update your browser.</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
|
@ -19,31 +19,39 @@
|
|||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="4kfMq14" resname="altcha.validator.server_validation_error">
|
<trans-unit id="4kfMq14" resname="altcha.validator.server_validation_error">
|
||||||
<source>altcha.validator.server_validation_error</source>
|
<source>altcha.validator.server_validation_error</source>
|
||||||
<target xml:space="preserve">Échec de la vérification. Réessayez plus tard.</target>
|
<target>Échec de la vérification. Réessayez plus tard.</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="7mZdXx_" resname="altcha.widget.error">
|
<trans-unit id="7mZdXx_" resname="altcha.widget.error">
|
||||||
<source>altcha.widget.error</source>
|
<source>altcha.widget.error</source>
|
||||||
<target xml:space="preserve">Échec de la vérification. Réesayez plus tard.</target>
|
<target>Échec de la vérification. Réesayez plus tard.</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="Yg33QZt" resname="altcha.widget.expired">
|
<trans-unit id="Yg33QZt" resname="altcha.widget.expired">
|
||||||
<source>altcha.widget.expired</source>
|
<source>altcha.widget.expired</source>
|
||||||
<target xml:space="preserve">Vérification expirée. Réessayez.</target>
|
<target>Vérification expirée. Réessayez.</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="3y0.Bhb" resname="altcha.widget.label">
|
<trans-unit id="3y0.Bhb" resname="altcha.widget.label">
|
||||||
<source>altcha.widget.label</source>
|
<source>altcha.widget.label</source>
|
||||||
<target xml:space="preserve">Je ne suis pas un robot</target>
|
<target>Je ne suis pas un robot</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="QFBWtGD" resname="altcha.widget.verified">
|
<trans-unit id="QFBWtGD" resname="altcha.widget.verified">
|
||||||
<source>altcha.widget.verified</source>
|
<source>altcha.widget.verified</source>
|
||||||
<target xml:space="preserve">Vérifié</target>
|
<target>Vérifié</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="SfOrgtj" resname="altcha.widget.verifying">
|
<trans-unit id="SfOrgtj" resname="altcha.widget.verifying">
|
||||||
<source>altcha.widget.verifying</source>
|
<source>altcha.widget.verifying</source>
|
||||||
<target xml:space="preserve">Vérification en cours...</target>
|
<target>Vérification en cours...</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
<trans-unit id="9dhbPuz" resname="altcha.widget.waitalert">
|
<trans-unit id="9dhbPuz" resname="altcha.widget.waitalert">
|
||||||
<source>altcha.widget.waitalert</source>
|
<source>altcha.widget.waitalert</source>
|
||||||
<target xml:space="preserve">Vérification en cours... veuillez patienter.</target>
|
<target>Vérification en cours... veuillez patienter.</target>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="9k5hI.D" resname="altcha.widget.title">
|
||||||
|
<source>altcha.widget.title</source>
|
||||||
|
<target>Vérification</target>
|
||||||
|
</trans-unit>
|
||||||
|
<trans-unit id="vGcy2C3" resname="altcha.widget.info">
|
||||||
|
<source>altcha.widget.info</source>
|
||||||
|
<target>Veuillez cocher la case ci dessus afin de valider que vous n'êtes pas un robot. Si vous rencontrez un problème lors de cette action, mettez à jour votre navigateur.</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user