Recaptcha.Blazored 1.0.3

dotnet add package Recaptcha.Blazored --version 1.0.3                
NuGet\Install-Package Recaptcha.Blazored -Version 1.0.3                
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="Recaptcha.Blazored" Version="1.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Recaptcha.Blazored --version 1.0.3                
#r "nuget: Recaptcha.Blazored, 1.0.3"                
#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.
// Install Recaptcha.Blazored as a Cake Addin
#addin nuget:?package=Recaptcha.Blazored&version=1.0.3

// Install Recaptcha.Blazored as a Cake Tool
#tool nuget:?package=Recaptcha.Blazored&version=1.0.3                

BlazoredRecaptcha

A really simple Blazor server-side reCAPTCHA v3 library, allows you to do the reCAPTCHA token generation and verification in the server, instead of the client.

License

Licensed under the MIT license, see LICENSE.md

Requirements

  • Visual Studio 2019

Warnings

This project is designed and tested on Blazor server-side, and it potentially could work on Blazor WASM (WebAssembly). It WILL NOT work on Razor pages as it depends on IJSRuntime which Razor lacks.

Compiling / Installation

To compile from source, if you so wish to, just simply clone the source code

git clone https://github.com/HarryTq/BlazoredRecaptcha.git

Then open the .sln file with Visual Studio 2019 and just rebuild. It should fetch the NuGet packages for you.

Installation

You can install it via our new NuGet package!

PM> Install-Package Recaptcha.Blazored

Or search for Recaptcha.Blazored and install via the NuGet UI on Visual Studio or any other IDE (Rider, etc.)

Usage / documentation

Let's get started. To begin using the library, simply add it to your ServiceCollection:

services.AddRecaptcha(options => 
{
  options.SiteKey = "My site key";
  options.SecretKey = "My secret key";
});

(you can also combine this with Microsoft's standard appsettings system, I would recommend using appsettings instead of hard-coding the keys into your application)

This will inject the RecaptchaService into your ServiceCollection. You can now access it from any Blazor page like this:

@inject RecaptchaService RecaptchaService

Then copy the JS library (js/blazoredRecaptcha.min.js) to the wwwroot folder and add it in your _Host.cshtml file

<script type="text/javascript" async defer src="~/blazoredRecaptcha.min.js"></script>

To get started generating tokens, just simply call this method:

var token = await RecaptchaService.GenerateCaptchaTokenAsync("action");

Then, with that token, you can validate it with Google to check if the user is likely a bot or not:

if (!await RecaptchaService.VerifyCaptchaAsync(token))
{
  Console.WriteLine("Begone bot!");
}

Open-source libraries

Thank you for all these people below for your amazing open-source libraries that made this project possible

Contributors

Thank you for all these people for contributing to the BlazoredRecaptcha source code, and helping make it better for everyone

none yet 😦

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
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
1.0.3 1,048 4/14/2022
1.0.2 428 4/14/2022
1.0.1 429 4/14/2022

- Update some standards to work better