SyCaptchaBundle is a form protection bundle made for Symfony, including a set of CAPTCHA challenges that should stop any malicious requests from submitting your forms.

Overview

SyCaptchaBundle

SyCaptchaBundle is a form protection bundle made for Symfony, including a set of CAPTCHA challenges that should stop any malicious requests from submitting your forms.

Supported CAPTCHAs

There are three types of supported CAPTCHAs as of now

  1. reCaptcha V2 - By Google
  2. reCaptcha V3 - By Google
  3. hCaptcha - By Intuition Machines

Invisible reCaptcha V2 isn't supported, due to the fact that it's 'lower' end version of reCaptcha V3

Installation

With composer require

composer require matt/sycaptcha

Configuration without symfony/flex

You can configure all the needed files manually when not having an option to install/upgrade to symfony/flex

1. Register the bundle

Register bundle into config/bundles.php Symfony 4/5

return [
    Matt\SyCaptchaBundle\SyCaptchaBundle::class => ['all' => true],
];

Register bundle into app/AppKernel.php Symfony 3 and below

public function registerBundles()
{
    return [
        new Matt\SyCaptchaBundle\SyCaptchaBundle(),
    ];
}

2. Add configuration files

config/packages/sy_captcha.yaml (or app/config/config.yml if using Symfony 3 or below)

sy_captcha:  
  recaptcha_v2:  
    site_key: 'site_key'  
    secret_key: 'secret_key'  

Usage

Let's finally get to the part about how you can integrate those CAPTCHAS into your forms.

1. Create form and add the CAPTCHA protection

You can add all three CAPTCHAS into the form at the same time (yes, it's overkill), however, they all need to be configured properly

add('captcha', SyCaptchaHCaptchaType::class);
  }  
}

2. Configure the CAPTCHA if needed

There are series of parameters that can be used to configure the CAPTCHA and it's scripts. Most of them are being set via configuration file (more in whole configuration section) but few of them are being declared via form options. Those are

  1. action_name - Sets the action name (reCaptcha V3 Only)
  2. theme - Sets the CAPTCHA theme to either light / dark (reCaptcha V2 and hCaptcha Only)
  3. script_nonce_csp - Sets the nonce of all scripts injected via CAPTCHA widget

Full config explanation

The whole config looks like this now

sy_captcha:  
  enabled: true  
  recaptcha_v2:  
    site_key: null  
    secret_key: null  
    api_host: 'www.google.com'  
  recaptcha_v3:  
    site_key: null  
    secret_key: null  
    api_host: 'www.google.com'  
    score_threshold: 0.5  
  hcaptcha:  
    site_key: null  
    secret_key: null  
    api_host: 'js.hcaptcha.com'  
    invisible: false

As you can see there are few configurable options, and their default values. Let's break the script a little, please note that some options are only available for hCaptcha, some for reCaptcha only and so forth.

  • enabled - Defines whether the CAPTCHA verification is, or is not enabled can be used to (for example) disable whole page verification on DEV
  • site_key - This is the value you receive via your reCaptcha or hCaptcha dashboard, it represents the public key of your site
  • secret_key - This is the value you receive via your reCaptcha or hCaptcha dashboard, it represents the secret key of your website, that's used to check the response
  • score_threshold - reCaptcha V3 sends users score via the response as well, setting score_threshold to lower than 0.5 will make it even harder for bots (but for people as well) to pass this CAPTCHA
  • api_host - Can be used to enable CAPTCHAs worldwide, you can not access www.google.com in China, thus their CAPTCHA would not work there as well, that's why you'd need to set it to www.recaptcha.net

Including .ENV values into config

This is just a little tip, but you can include .ENV values in your Symfony config. All you need to do is to reference it via %env(VARIABLE)% tag in your config.

sy_captcha:
    enabled: '%env(SYCAPTCHA_ENABLED)%'

TODO

A little list of plans for the future

  • Cloudflare IP resolution, (implementing resolved interface)
  • Translations
  • Custom styles (meaning .css styles)
You might also like...
Automatic Encrypt and Decrypt your database data. Tested and used on Laravel 8

Laravel Encrypt Database Automatic Encrypt and Decrypt your database data. Tested and used on Laravel 8. I'm yet building the tests. Important Note th

Protect your server from griefer

A Simple anti grief PocketMine-MP Plugin

The Security component provides a complete security system for your web application.

Security Component The Security component provides a complete security system for your web application. It ships with facilities for authenticating us

Block malicious scripts using botscout.com protection for your laravel app
Block malicious scripts using botscout.com protection for your laravel app

Laravel BotScout Protect your website against automated scripts using the botscout.com API. Installation You can install the package via composer: com

My aim is to make a complete website that should have all the essential parts a website should have.
My aim is to make a complete website that should have all the essential parts a website should have.

Gaming-Ninja I aim to make a complete website that should have all the essential parts a website should have. https://gamingninja-3399.000webhostapp.c

Symfony bundle that provides Cross Site Request Forgery (CSRF or XSRF) protection for client-side applications

CSRF Cookie Bundle This Symfony bundle provides Cross Site Request Forgery (CSRF or XSRF) protection for client-side applications requesting endpoints

Collection of CTF Web challenges I made

My CTF Web Challenges This is the repository of all CTF challenges I made, including the source code, write-up and idea explanation! Hope you like it

Multi captcha package for CodeIgniter 4.x, supports 4 captcha services
Multi captcha package for CodeIgniter 4.x, supports 4 captcha services

Multi captcha package for CodeIgniter 4.x. Support Arcaptcha(a free and professional Iranian product),Bibot(a free Iranian product),Recaptcha(an googel product) and hCaptcha.Comes with rate limiting support.

Stop duplicating your Eloquent query scopes and constraints in PHP. This package lets you re-use your query scopes and constraints by adding them as a subquery.

Laravel Eloquent Scope as Select Stop duplicating your Eloquent query scopes and constraints in PHP. This package lets you re-use your query scopes an

Easy management of Virtualization technologies including KVM, Xen, OpenVZ, Virtuozzo, and LXC/LXD including unified commands, monitoring, template management, and many more features.

ProVirted About Easy management of Virtualization technologies including KVM, Xen, OpenVZ, Virtuozzo, and LXC/LXD including unified commands, monitori

A Symfony2 bundle that integrates Select2 as a drop-in replacement for a standard entity field on a Symfony form.
A Symfony2 bundle that integrates Select2 as a drop-in replacement for a standard entity field on a Symfony form.

select2entity-bundle Introduction This is a Symfony bundle which enables the popular Select2 component to be used as a drop-in replacement for a stand

Laravel style FormRequests for Symfony; inspired by adamsafr/form-request-bundle

Somnambulist Form Request Bundle An implementation of form requests from Laravel for Symfony based on the original work by Adam Sapraliev. Requirement

A complete anti-cheat to defend the server from malicious users.
A complete anti-cheat to defend the server from malicious users.

Advanced Anti-Cheat vAlpha An Anti-Cheat plugin with various preventions and support for apis ≤ 2.0.0. 📃 Features Options that are not checked will s

Public solutions and challenges from sinf ctf 2021

SINFCTF2021 CTF Challenges (and official solutions) created for SINFCTF2021, a companion CTF for Semana de Informática 2021. There's a folder for each

Patches that prevent malicious Minecraft plugins from saturating host internet resources for DDoS.
Patches that prevent malicious Minecraft plugins from saturating host internet resources for DDoS.

Minecraft Host DoS Botnet Patches Patches that prevent malicious Minecraft plugins from saturating host internet resources for DDoS. In recent events,

A dockerized PHP application containing some file upload vulnerability challenges (scenarios)

File Upload Vulnerability Scenarios (Challenges) This repository is a dockerized PHP application containing some file upload vulnerability challenges

Quick start -d/reload/restart/stop hyperf(~2.1.0 & ~2.2.0) server

hyperf-helper 1. quick start -d/reload/restart/stop server 2. support hyperf ~2.1.0 & ~2.2.0 3. support CentOS7+, Ubuntu 18.0.4+, macOS 4. support swo

Stop players from having spaces in their name in Pocketmin Servers.
Stop players from having spaces in their name in Pocketmin Servers.

SpaceRemover Engelish Stop players from having spaces in their name in Pocketmin Servers. Preview Help ‼ If your server does not have players with nam

A demo of how to use filament/forms to build a user-facing Form Builder which stores fields in JSON.

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Releases(v1.0.0)
Owner
Matt
Hello there, I'm Matt, enthusiastic student that loves coding and learning new things about coding.
Matt
㊙️ AntiXSS | Protection against Cross-site scripting (XSS) via PHP

㊙️ AntiXSS "Cross-site scripting (XSS) is a type of computer security vulnerability typically found in Web applications. XSS enables attackers to inje

Lars Moelleken 570 Dec 16, 2022
JObfuscator — Java Source Code Obfuscation & Protection

JObfuscator is a source code obfuscator for the Java programming language. It can protect your Java source code and algorithms from hacking, cracking, reverse engineering, decompilation, and technology theft.

Bartosz Wójcik 8 Nov 6, 2022
Akismet: Spam Protection for MODX

Akismet: Spam Protection for MODX Developed by modmore Introduction Akismet is an advanced spam protection service that uses AI to analyse form submis

modmore | More for MODX 3 Nov 12, 2021
2 functions which work together to sanitize the the information from a form from SQL_Inyection.

Form_sanitizer 2 functions which work together to sanitize the the information from a form from SQL_Inyection. How to use the 2 functions Once you cop

Gorrian 1 Jul 19, 2022
phpcs-security-audit is a set of PHP_CodeSniffer rules that finds vulnerabilities and weaknesses related to security in PHP code

phpcs-security-audit is a set of PHP_CodeSniffer rules that finds vulnerabilities and weaknesses related to security in PHP code.

Floe design + technologies 654 Dec 28, 2022
[OUTDATED] Two-factor authentication for Symfony applications 🔐 (bunde version ≤ 4). Please use version 5 from https://github.com/scheb/2fa.

scheb/two-factor-bundle ⚠ Outdated version. Please use versions ≥ 5 from scheb/2fa. This bundle provides two-factor authentication for your Symfony ap

Christian Scheb 389 Nov 15, 2022
PHP frontend for security.symfony.com

SensioLabs Security Checker WARNING: Don't use this piece of software anymore as the underlying web service will stop working at the end of January 20

SensioLabs 2k Dec 25, 2022
Fides provides your servers with a trusted CA certificate, and signs your OpenSSH certificates with the same key

Fides is an SSH certificate signing server. It enables zero-trust infrastructure for your engineers by dynamically, and transparently, issuing short-lived certificates with clearly defined permissions.

Moritz Friedrich 3 Dec 28, 2022
PHPIDS (PHP-Intrusion Detection System) is a simple to use, well structured, fast and state-of-the-art security layer for your PHP based web application

PHPIDS PHPIDS (PHP-Intrusion Detection System) is a simple to use, well structured, fast and state-of-the-art security layer for your PHP based web ap

null 752 Jan 3, 2023
Obfuscate your data by generating reversible, non-sequential, URL-safe identifiers.

Laravel Hashid Laravel Hashid provides a unified API across various drivers such as Base62, Base64, Hashids and Optimus, with support for multiple con

Elf Sundae 390 Nov 16, 2022