Skip to content

Add logging to AltchaField for validation failures and misconfigurations#40

Open
hleroy wants to merge 1 commit intoaboutcode-org:mainfrom
hleroy:main
Open

Add logging to AltchaField for validation failures and misconfigurations#40
hleroy wants to merge 1 commit intoaboutcode-org:mainfrom
hleroy:main

Conversation

@hleroy
Copy link
Copy Markdown

@hleroy hleroy commented Apr 5, 2026

Adds a module-level logger and a log_warning() method on AltchaField (overridable by subclasses) that emits warnings in the following cases:

  • ALTCHA_VERIFICATION_ENABLED is False — silent bypass of CAPTCHA protection is now visible in logs
  • altcha.verify_solution raises an unexpected exception
  • Token verification fails (with the reason returned by the library)
  • Payload base64/JSON decoding fails
  • A replay attack is detected

Without logging, all these failure paths were silent, making it difficult to distinguish misconfiguration from attacks or bugs in production.

…gurations

Signed-off-by: Hervé Le Roy <hleroy@hleroy.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant