Documentation ¶
Overview ¶
Package turnstile creates a secure by default humanity verifier backed by Cloudflare's Turnstile service.
On the client include the the following script:
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback" async defer></script>
Cloudflare Turnstile documentation: <https://developers.cloudflare.com/turnstile/>
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*options) error
func WithAllowedActions ¶
func WithDefaultOptions ¶
func WithDefaultOptions() Option
func WithEndpoint ¶
func WithHTTPClient ¶
func WithHostname ¶
func WithSecret ¶
type Request ¶
type Request struct { // Secret key provided by Cloudflare. Secret string `json:"secret"` // Response key provided by the verification subject. Response string `json:"response"` // RemoteIP is the subject's IP address. It is optional but improves the verification accuracy. RemoteIP string `json:"remoteip"` }
type Response ¶
type Response struct { // Success is true if the verification passed. Success bool `json:"success"` // ChallengeTime when the verfication passed in ISO 8601 format. ChallengeTime string `json:"challenge_ts"` // Action name of the validation, set by the subject. Must match the information inside [Request.Response]. Action string `json:"action"` // Hostname of the site that requested verification. Hostname string `json:"hostname"` // ErrorCodes of any problems that were encountered. // // https://developers.cloudflare.com/turnstile/get-started/server-side-validation/#error-codes ErrorCodes []string `json:"error-codes"` // CData is client subject data. CData string `json:"cdata"` }
Click to show internal directories.
Click to hide internal directories.