Persilsoft.Turnstile.Server 1.0.2

dotnet add package Persilsoft.Turnstile.Server --version 1.0.2
                    
NuGet\Install-Package Persilsoft.Turnstile.Server -Version 1.0.2
                    
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.2" />
                    
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.2" />
                    
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.2
                    
#r "nuget: Persilsoft.Turnstile.Server, 1.0.2"
                    
#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.
#addin nuget:?package=Persilsoft.Turnstile.Server&version=1.0.2
                    
Install Persilsoft.Turnstile.Server as a Cake Addin
#tool nuget:?package=Persilsoft.Turnstile.Server&version=1.0.2
                    
Install Persilsoft.Turnstile.Server 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 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 was computed.  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.Membership.Core

Contains services, interactors, presenters and controllers for membership backend projects

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 153 5/31/2025
1.0.1 143 5/28/2025
1.0.0 144 5/28/2025