Help us shape the future of Go! Take the 2026 Go Developer Survey

challenge

package
v1.21.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package challenge verifies Cloudflare Turnstile tokens, the human check guarding sign-in, registration, password resets and guest purchases.

Index

Constants

View Source
const SiteVerifyURL = "https://challenges.cloudflare.com/turnstile/v0/siteverify"

SiteVerifyURL is Cloudflare's Turnstile verification endpoint.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Secret is the site's Turnstile secret key; required.
	Secret string
	// Timeout bounds one verification; 10 seconds when zero.
	Timeout time.Duration
	// URL is the verification endpoint; SiteVerifyURL when empty.
	URL string
}

Config configures a Turnstile client.

type Service

type Service interface {
	// Verify reports whether token is a valid Turnstile response issued to
	// the client at ip. An error means the verification could not be done.
	Verify(ctx context.Context, token string, ip string) (bool, error)
}

Service verifies Turnstile tokens.

func New

func New(config Config) Service

New returns a Turnstile client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL