### Install AltchaBundle via Composer Source: https://github.com/tito10047/altcha-bundle/blob/main/README.md Run this command in your terminal to add the package to your project. ```bash composer require tito10047/altcha-bundle ``` -------------------------------- ### Install iconcaptcha-bundle with Composer Source: https://github.com/tito10047/altcha-bundle/blob/main/README.md Run this command to install the tito10047/iconcaptcha-bundle package. It is a self-hosted Symfony integration of IconCaptcha, requiring no third-party service or API key. ```bash composer require tito10047/iconcaptcha-bundle ``` -------------------------------- ### Import AltchaBundle Routes Source: https://github.com/tito10047/altcha-bundle/blob/main/README.md Add the bundle routes to your YAML configuration. ```yml altcha: resource: '@AltchaBundle/config/routes.yml' type: yaml ``` -------------------------------- ### Configure AltchaBundle in altcha.yaml Source: https://github.com/tito10047/altcha-bundle/blob/main/README.md Define the bundle settings in your configuration file. ```yml altcha: enable: true hmacSignature: '%env(APP_SECRET)%' # Replaces deprecated hmacKey hmacAlgorithm: 'SHA-256' hmacKeySignature: ~ # Optional signature key cost: 5000 counter_min: 5000 counter_max: 10000 timeout: 30.0 floating: true overlay: false use_stimulus: false include_script: true hide_logo: false hide_footer: false when@test: altcha: enable: false ``` -------------------------------- ### Configure Sentinel for Altcha Source: https://github.com/tito10047/altcha-bundle/blob/main/README.md Set up the Sentinel server endpoint and API key for challenge generation and verification. ```yml altcha: sentinel: base_url: 'http://localhost:8080' api_key: 'key_xxxxxxxxxxxx' ``` -------------------------------- ### Configure Altcha for UX Live Components Source: https://github.com/tito10047/altcha-bundle/blob/main/README.md Adjust settings to support UX Live components. ```yml altcha: use_stimulus: true floating: false include_script: false ``` -------------------------------- ### Register AltchaBundle in bundles.php Source: https://github.com/tito10047/altcha-bundle/blob/main/README.md Add the bundle to your application's bundle configuration file. ```php Tito10047\AltchaBundle\AltchaBundle::class => ['all' => true] ``` -------------------------------- ### Configure Webpack Encore for Altcha Source: https://github.com/tito10047/altcha-bundle/blob/main/README.md Update your webpack configuration and altcha settings for Webpack Encore usage. ```js //webpack.config.js module.exports = Encore.getWebpackConfig(); module.exports.resolve.alias["altcha/dist/i18n/all.js"]='altcha/i18n'; ``` ```yaml #config/packages/altcha.yaml altcha: use_stimulus: true include_script: false ``` -------------------------------- ### Configure Security Access Control Source: https://github.com/tito10047/altcha-bundle/blob/main/README.md Ensure the challenge endpoint is publicly accessible when using global access restrictions. ```yaml access_control: - { path: ^/altcha/challenge, roles: PUBLIC_ACCESS } - { path: ^/, roles: ROLE_USER } ``` -------------------------------- ### Update webpack alias for altcha i18n Source: https://github.com/tito10047/altcha-bundle/blob/main/MIGRATE.md Update the custom alias in webpack.config.js to point to the new i18n file path. The 'Before' line shows the old alias, and the 'After' line shows the new one. ```javascript // Before module.exports.resolve.alias["altcha/dist/altcha.i18n.js"] = 'altcha/i18n'; // After module.exports.resolve.alias["altcha/dist/i18n/all.js"] = 'altcha/i18n'; ``` -------------------------------- ### Integrate AltchaType in Symfony Form Source: https://github.com/tito10047/altcha-bundle/blob/main/README.md Add the AltchaType to your form builder to include the captcha. ```php add('name', TextType::class, ['label' => false, 'attr' => ['placeholder' => 'name']]) ->add('message', TextareaType::class, ['label' => false, 'attr' => ['placeholder' => 'message']]) ->add('security', AltchaType::class, [ 'label' => false, 'floating' => true, 'hide_logo' => false, 'hide_footer' => false, // Optional: override global config // 'cost' => 5000, // 'timeout' => 30.0, // 'counter_min' => 5000, // 'counter_max' => 10000, ]) ->add('submit', SubmitType::class) ; } public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ 'data_class' => Contact::class, ]); } } ``` -------------------------------- ### Add IconCaptcha field to Symfony form type Source: https://github.com/tito10047/altcha-bundle/blob/main/README.md Add this field to your Symfony form type to include the IconCaptcha challenge. The visitor must pick the least-common icon out of five to eight. The label is set to false. ```php ->add('security', \Tito10047\IconcaptchaBundle\Type\IconCaptchaType::class, [ 'label' => false, ]) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.