xsanz/magento2-module-admin-color-captcha 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

xsanz/magento2-module-admin-color-captcha

最新稳定版本:1.0.0

Composer 安装命令:

composer require xsanz/magento2-module-admin-color-captcha

包简介

Magento 2 admin image CAPTCHA with optional per-character colors and grayscale noise (XavierSanz_ColorCaptcha).

README 文档

README

Admin image CAPTCHA enhancement for Magento 2: optional per-character colors and grayscale noise for better readability on the backend login (and other admin forms that use the default image CAPTCHA). Storefront CAPTCHA is unchanged.

Requirements

  • Magento 2.4.x (Open Source or Adobe Commerce) with Magento_Captcha enabled
  • PHP 8.x (match your Magento installation)
  • GD extension with FreeType (imagefttext) support (same as core image CAPTCHA)

Installation

Option A — app/code (typical)

  1. Ensure the module lives at:

    app/code/XavierSanz/ColorCaptcha/

  2. Enable the module and update the database:

    bin/magento module:enable XavierSanz_ColorCaptcha
    bin/magento setup:upgrade
  3. Recompile DI (production mode) and flush caches:

    bin/magento setup:di:compile
    bin/magento cache:flush

Option B — Composer (path repository)

The package name is xsanz/magento2-module-admin-color-captcha (see composer.json). In the Magento project composer.json, add a path repository pointing at this directory, then:

composer require xsanz/magento2-module-admin-color-captcha:^1.0
bin/magento module:enable XavierSanz_ColorCaptcha
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush

Adjust the version constraint if you tag releases (e.g. ^1.0).

How to use

1. Turn on admin CAPTCHA (core)

Per-character colors only apply when Admin CAPTCHA is enabled.

  1. In the Admin, go to Stores → Configuration.
  2. Open Advanced → Admin → CAPTCHA.
  3. Set Enable CAPTCHA in Admin to Yes and configure forms, mode, and attempts as needed.

2. Enable per-character color mode (this module)

In the same section (Advanced → Admin → CAPTCHA), below the standard fields:

  1. Set Enable Per-Character Color CAPTCHA to Yes.
  2. Optionally adjust Text luminance and Noise luminance fields (all are 0–255, BT.601 luminance).

Defaults (from etc/config.xml, restorable via Use Default in the UI):

Setting Default Purpose
Enable Per-Character Color CAPTCHA No (opt-in) Off = stock Laminas image; On = colored glyphs + gray noise
Text luminance min 0 Darkest allowed brightness for glyphs
Text luminance max 105 Lightest allowed for glyphs (keep low for contrast on white)
Noise luminance min 140 Darkest gray for dots/lines
Noise luminance max 160 Lightest gray for noise

Keep text luminance max clearly below noise luminance min so letters stay darker than the noise.

image

3. When you will see it

Admin CAPTCHA appears according to your Displaying Mode (e.g. after failed login attempts). Refresh the CAPTCHA image with the reload control next to the image if needed.

image

Behavior notes

  • Admin only: The module replaces Magento\Captcha\Model\DefaultModel only in the adminhtml area. Customer-facing CAPTCHA is not affected.
  • With the feature off: Behavior matches core (single-color Laminas image pipeline).
  • With the feature on: Each character is drawn in a random color within the text luminance bounds; noise is grayscale only; distortion uses an RGB-preserving resample so colors remain visible after the wave transform.

Configuration scope

The CAPTCHA group is available per website scope in Configuration. If you use multiple websites, set values under the scope where you manage admin settings (often Default Config).

Uninstall

bin/magento module:disable XavierSanz_ColorCaptcha
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush

Remove the module files if you no longer need them. Config keys under admin/captcha/* for this module may remain in the core_config_data table until cleaned up manually if required.

Support

Issues and improvements: maintain in your project or VCS as appropriate for XavierSanz_ColorCaptcha.

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固