Zongsoft.Security.Captcha 2.4.0

dotnet add package Zongsoft.Security.Captcha --version 2.4.0
                    
NuGet\Install-Package Zongsoft.Security.Captcha -Version 2.4.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Zongsoft.Security.Captcha" Version="2.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Zongsoft.Security.Captcha" Version="2.4.0" />
                    
Directory.Packages.props
<PackageReference Include="Zongsoft.Security.Captcha" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Zongsoft.Security.Captcha --version 2.4.0
                    
#r "nuget: Zongsoft.Security.Captcha, 2.4.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Zongsoft.Security.Captcha@2.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Zongsoft.Security.Captcha&version=2.4.0
                    
Install as a Cake Addin
#tool nuget:?package=Zongsoft.Security.Captcha&version=2.4.0
                    
Install as a Cake Tool

Zongsoft.Security.Captcha Captcha Plugin Library

License NuGet Version NuGet Downloads GitHub Stars

English | 简体中文


Overview

Zongsoft.Security.Captcha is a sub-plugin of the security plugin library for the Zongsoft open-source framework. It provides captcha-related functionality.

The built-in Authencode scheme generates a PNG challenge, stores the answer in IDistributedCache, and exchanges a correct answer for a short-lived, one-time confirmation token. It integrates with ICaptcha, the Security Web controller, and the X-Captcha response header.

Installation and Requirements

dotnet add package Zongsoft.Security.Captcha

Deploy Zongsoft.Security.Captcha.plugin; it depends on the main Security plugin. The host must provide IDistributedCache. In a multi-instance deployment the cache must be shared, otherwise a challenge issued by one node cannot be verified by another.

Browser/API Flow

  1. Request the Authencode scheme through the Security CAPTCHA endpoint.
  2. Display the returned image/png; read its challenge token from the X-Captcha header.
  3. Submit the answer as token:code (an equals sign is also accepted by the provider).
  4. Receive a confirmation token and pass it to the protected security workflow.
  5. The final verification consumes the confirmation and original challenge entries.

The challenge expires after 10 minutes and a successful answer creates a confirmation valid for 5 minutes. Confirmation verification removes both cache entries, making the confirmation single-use.

💡 AuthencodeImager.Generate(code, width, height) can generate the image directly, but application flows should normally use ICaptcha so caching, formatting, and scheme matching remain consistent.

Security and Accessibility

🚨 A visual CAPTCHA is only one abuse-control signal. Apply endpoint rate limits and monitoring, use TLS, do not log answers or tokens, and do not treat a CAPTCHA as identity proof. Provide an accessible alternative for users who cannot solve an image challenge.

Image rendering uses ImageSharp and its font/drawing packages, with a minimum size of 60 × 20 pixels. Verify that fonts are available and that image dimensions, proxy/header rules, and cache expiry behave consistently in the target environment.

References

Plugin-Based Integration

Compose this feature through the host; a package reference supplies compile-time APIs, while plugin loading also requires deployed manifests and runtime assets. See the complete plugin workflow.

Use a Web host with Security configured and a registered distributed-cache provider. Service discovery exposes Authencode and its formatter; do not register a second challenge implementation with the same scheme inadvertently.

Runtime artifact Source of truth
Zongsoft.Security.Captcha Zongsoft.Security.Captcha.plugin
File copying and dependencies Zongsoft.Security.Captcha.deploy

Add this fragment to an existing host .deploy (retain Main and the host’s other base manifests; do not replace the whole file):

[plugins zongsoft data]
nuget:Zongsoft.Data

[plugins zongsoft security]
nuget:Zongsoft.Security

[plugins zongsoft security captcha]
nuget:Zongsoft.Security.Captcha

Run dotnet deploy against a test deployment as explained in the workflow, with the host's framework, platform, architecture and, where needed, site. Pin compatible versions in real deployments; application dependencies such as databases, caches or commercial runtimes are still separate prerequisites.

Additional artifacts listed by the deployment manifest include Zongsoft.Security.Captcha.plugin. Retain assemblies, dependencies and satellite resource directories as well. Restart the host after deployment, check plugin loading and service/driver registration, then verify the workflow above; copied files alone do not prove that the feature is active.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.4.0 93 10/24/2026
2.3.0 93 10/23/2026
2.2.0 95 10/10/2026
2.1.0 321 8/29/2025
2.0.0 216 2/24/2025