Persilsoft.Turnstile.Server 1.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Persilsoft.Turnstile.Server --version 1.0.4
                    
NuGet\Install-Package Persilsoft.Turnstile.Server -Version 1.0.4
                    
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="Persilsoft.Turnstile.Server" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Persilsoft.Turnstile.Server" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="Persilsoft.Turnstile.Server" />
                    
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 Persilsoft.Turnstile.Server --version 1.0.4
                    
#r "nuget: Persilsoft.Turnstile.Server, 1.0.4"
                    
#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 Persilsoft.Turnstile.Server@1.0.4
                    
#: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=Persilsoft.Turnstile.Server&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=Persilsoft.Turnstile.Server&version=1.0.4
                    
Install as a Cake Tool

Persilsoft.Turnstile.Server

Persilsoft.Turnstile.Server is a backend library that provides a ready-to-use service to verify CAPTCHA tokens using Cloudflare Turnstile.
It eliminates the need to manually call the siteverify endpoint — you just call a method from the injected service.


🚀 Installation

  1. Install the NuGet package:
dotnet add package Persilsoft.Turnstile.Server
  1. Register the Turnstile services in your backend:
using Persilsoft.Turnstile.Server.Options;
using Persilsoft.Turnstile.Server;

Action<TurnstileOptions> turnstileOptionsConfigurator = options =>
    builder.Configuration.GetRequiredSection(TurnstileOptions.SectionKey).Bind(options);

builder.Services.AddTurnstileServices(turnstileOptionsConfigurator);

🔧 Configuration

Add the following section to your appsettings.json:

"TurnstileOptions": {
  "VerifyEndpoint": "https://challenges.cloudflare.com/turnstile/v0/siteverify",
  "SecretKey": "YOUR_SECRET_KEY"
}
Key Description
VerifyEndpoint The Cloudflare Turnstile API endpoint for verification (keep default).
SecretKey Your private secret key provided by Cloudflare.

✅ Example Usage

You can inject the TurnstileService into any endpoint or controller to validate the CAPTCHA token sent from your frontend:

Example Minimal API Endpoint

namespace Persilsoft.Turnstile.Server.Tests.Endpoints;

internal static class DemoEndpoints
{
    public static WebApplication UseDemoEndpoints(this WebApplication app)
    {
        app
            .MapPost("send", Send)
            .Produces(StatusCodes.Status200OK)
            .Produces(StatusCodes.Status500InternalServerError)
            .WithTags("Turnstile")
            .WithName(nameof(Send))
            .WithSummary("Send demo data")
            .WithDescription("Receives demo data along with a Turnstile token and validates it using Cloudflare SiteVerify.");

        return app;
    }

    private static async Task<IResult> Send(DemoModel dto, TurnstileService service)
    {
        var isValid = await service.VerifyAsync(dto.CaptchaToken);
        if (!isValid)
        {
            throw new BadHttpRequestException($"Token verification failed.");
        }

        Console.WriteLine("Save data to the database...");

        return TypedResults.Ok();
    }
}

Example DTO

public class DemoModel
{
    public string Name { get; set; } = string.Empty;
    public string CaptchaToken { get; set; } = string.Empty;
}

📜 License

MIT License


✨ Credits

Developed by Persilsoft.
Secure and simplify CAPTCHA verification on the server.

Product Compatible and additional computed target framework versions.
.NET 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 (1)

Showing the top 1 NuGet packages that depend on Persilsoft.Turnstile.Server:

Package Downloads
Persilsoft.Captcha.Factory

Backend factory implementation for multiple captcha providers (ReCaptcha v3, Cloudflare Turnstile). Provides automatic endpoint registration (POST /captcha/verify) and dependency injection configuration for ASP.NET Core applications. Works seamlessly with Persilsoft.Recaptcha.Blazor for complete full-stack captcha verification.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6 172 12/13/2025
1.0.5 159 12/13/2025
1.0.4 138 12/13/2025
1.0.3 734 12/2/2025
1.0.2 1,599 5/31/2025
1.0.1 223 5/28/2025
1.0.0 226 5/28/2025