Compare commits
1 Commits
9cc4c7ac74
...
3f667eede1
Author | SHA1 | Date | |
---|---|---|---|
3f667eede1 |
15
readme.md
15
readme.md
@ -109,18 +109,3 @@ 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` |
|
||||
| `mariadb` | Base de donnée mariadb support du test | `3306` |
|
||||
| `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,29 +4,20 @@ namespace App\Flag\Controller;
|
||||
|
||||
use App\Flag\FlagEnum;
|
||||
use Predis\ClientInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
class FlagController extends AbstractController
|
||||
{
|
||||
#[Route('/flag/{flagName}', name: 'flag_update', methods: ['PUT'])]
|
||||
public function updateFlag(ClientInterface $redis, Request $request, string $flagName): Response
|
||||
#[Route('/flag', name: 'flag_update', methods: ['PUT'])]
|
||||
public function updateFlag(ClientInterface $redis, FlagEnum $flagName, bool $flagValue): Response
|
||||
{
|
||||
try {
|
||||
FlagEnum::from($flagName);
|
||||
} catch (\ValueError $e) {
|
||||
throw new \InvalidArgumentException('invalid flag name provided');
|
||||
}
|
||||
|
||||
$flagValue = $request->query->getBoolean('flagValue');
|
||||
|
||||
$redis->set($flagName, $flagValue);
|
||||
$redis->set($flagName->value, $flagValue);
|
||||
|
||||
return new JsonResponse(
|
||||
[\sprintf('flag %s has been %s.', $flagName, $flagValue ? 'enabled' : 'disabled')]
|
||||
[\sprintf('flag %s has been %s.', $flagName->value, $flagValue ? 'enabled' : 'disabled')]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ class LoginType extends AbstractType
|
||||
if ($this->flagAccessor->isFlagEnabled(FlagEnum::Altcha, $this->altchaEnabled)) {
|
||||
$builder->add('altcha', AltchaType::class, [
|
||||
'label' => false,
|
||||
'translation_domain' => 'form',
|
||||
]);
|
||||
};
|
||||
}
|
||||
|
@ -3,29 +3,16 @@
|
||||
.altcha label {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.panel-body {
|
||||
max-width: 400px;
|
||||
}
|
||||
</style>
|
||||
<div>
|
||||
<h3>
|
||||
{% trans from 'form' %}altcha.widget.title{% endtrans %}
|
||||
</h3>
|
||||
<div class="panel-body">
|
||||
<altcha-widget
|
||||
challengejson={{challengeJson}}
|
||||
name={{form.vars.full_name}}
|
||||
strings="{{translations}}"
|
||||
hidelogo
|
||||
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>
|
||||
<altcha-widget
|
||||
challengejson={{challengeJson}}
|
||||
name={{form.vars.full_name}}
|
||||
strings="{{translations}}"
|
||||
hidelogo
|
||||
hidefooter
|
||||
workers= {{ workers }}
|
||||
delay={{ delay }}
|
||||
{{ debug ? 'debug' : ''}}
|
||||
{{ mockError ? 'mockerror' : ''}}
|
||||
></altcha-widget>
|
||||
{% endblock %}
|
@ -6,23 +6,23 @@
|
||||
{% block body %}
|
||||
<div class="login-wrapper">
|
||||
<div class="login">
|
||||
{% if app.user %}
|
||||
<div class="mb-3">
|
||||
You are logged in as {{ app.user.login }}
|
||||
{% if app.user %}
|
||||
<div class="mb-3">
|
||||
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>
|
||||
{% 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>
|
||||
<h1 class="h3 mb-3 font-weight-normal">{% trans from 'view' %} sign_in {% endtrans %}</h1>
|
||||
{{form_start(loginForm)}}
|
||||
{{form_widget(loginForm)}}
|
||||
<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">
|
||||
{% trans from 'view' %} submit {% endtrans %}
|
||||
</button>
|
||||
{{form_end(loginForm)}}
|
||||
{{form_end(loginForm)}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -19,39 +19,31 @@
|
||||
</trans-unit>
|
||||
<trans-unit id="4kfMq14" resname="altcha.validator.server_validation_error">
|
||||
<source>altcha.validator.server_validation_error</source>
|
||||
<target>Verification failed. Try again later.</target>
|
||||
<target xml:space="preserve">Verification failed. Try again later.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="7mZdXx_" resname="altcha.widget.error">
|
||||
<source>altcha.widget.error</source>
|
||||
<target>Verification failed. Try again later.</target>
|
||||
<target xml:space="preserve">Verification failed. Try again later.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="Yg33QZt" resname="altcha.widget.expired">
|
||||
<source>altcha.widget.expired</source>
|
||||
<target>Verification expired. Try again.</target>
|
||||
<target xml:space="preserve">Verification expired. Try again.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3y0.Bhb" resname="altcha.widget.label">
|
||||
<source>altcha.widget.label</source>
|
||||
<target>I'm not a robot</target>
|
||||
<target xml:space="preserve">I'm not a robot</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="QFBWtGD" resname="altcha.widget.verified">
|
||||
<source>altcha.widget.verified</source>
|
||||
<target>Verified</target>
|
||||
<target xml:space="preserve">Verified</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="SfOrgtj" resname="altcha.widget.verifying">
|
||||
<source>altcha.widget.verifying</source>
|
||||
<target>Verifying...</target>
|
||||
<target xml:space="preserve">Verifying...</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="9dhbPuz" resname="altcha.widget.waitalert">
|
||||
<source>altcha.widget.waitalert</source>
|
||||
<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>
|
||||
<target xml:space="preserve">Verifying... please wait.</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
|
@ -19,39 +19,31 @@
|
||||
</trans-unit>
|
||||
<trans-unit id="4kfMq14" resname="altcha.validator.server_validation_error">
|
||||
<source>altcha.validator.server_validation_error</source>
|
||||
<target>Échec de la vérification. Réessayez plus tard.</target>
|
||||
<target xml:space="preserve">Échec de la vérification. Réessayez plus tard.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="7mZdXx_" resname="altcha.widget.error">
|
||||
<source>altcha.widget.error</source>
|
||||
<target>Échec de la vérification. Réesayez plus tard.</target>
|
||||
<target xml:space="preserve">Échec de la vérification. Réesayez plus tard.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="Yg33QZt" resname="altcha.widget.expired">
|
||||
<source>altcha.widget.expired</source>
|
||||
<target>Vérification expirée. Réessayez.</target>
|
||||
<target xml:space="preserve">Vérification expirée. Réessayez.</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="3y0.Bhb" resname="altcha.widget.label">
|
||||
<source>altcha.widget.label</source>
|
||||
<target>Je ne suis pas un robot</target>
|
||||
<target xml:space="preserve">Je ne suis pas un robot</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="QFBWtGD" resname="altcha.widget.verified">
|
||||
<source>altcha.widget.verified</source>
|
||||
<target>Vérifié</target>
|
||||
<target xml:space="preserve">Vérifié</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="SfOrgtj" resname="altcha.widget.verifying">
|
||||
<source>altcha.widget.verifying</source>
|
||||
<target>Vérification en cours...</target>
|
||||
<target xml:space="preserve">Vérification en cours...</target>
|
||||
</trans-unit>
|
||||
<trans-unit id="9dhbPuz" resname="altcha.widget.waitalert">
|
||||
<source>altcha.widget.waitalert</source>
|
||||
<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>
|
||||
<target xml:space="preserve">Vérification en cours... veuillez patienter.</target>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
|
Loading…
x
Reference in New Issue
Block a user