requester

package
v0.0.0-...-57b459a Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReCaptcha

type ReCaptcha interface {
	Verify(recaptchaResponse string) (VerifyResponse, error)
}

ReCaptcha verifies captcha response.

type ReCaptchaFake

type ReCaptchaFake struct {
	// contains filtered or unexported fields
}

ReCaptchaFake represents in memory implementation of ReCaptcha service.

func NewReCaptchaFake

func NewReCaptchaFake(verifyResponse VerifyResponse) ReCaptchaFake

NewReCaptchaFake creates in memory fake reCaptcha service with predefined response.

func (ReCaptchaFake) Verify

func (r ReCaptchaFake) Verify(recaptchaResponse string) (VerifyResponse, error)

Verify verifies captcha response.

type ReCaptchaVerifier

type ReCaptchaVerifier struct {
	// contains filtered or unexported fields
}

ReCaptchaVerifier verifies incoming network using ReCaptcha to prevent spamming attacks.

func NewReCaptchaVerifier

func NewReCaptchaVerifier(service ReCaptcha) ReCaptchaVerifier

NewReCaptchaVerifier creates new ReCaptcha-backed request verifier.

func (ReCaptchaVerifier) IsHuman

func (r ReCaptchaVerifier) IsHuman(recaptchaResponse string) (bool, error)

IsHuman checks whether the request is sent by a human user.

type Verifier

type Verifier interface {
	IsHuman(recaptchaResponse string) (bool, error)
}

Verifier verifies incoming network to prevent cyber attacks.

type VerifierFake

type VerifierFake struct{}

VerifierFake turns off human verification during local development.

func NewVerifierFake

func NewVerifierFake() VerifierFake

NewVerifierFake creates new fake request verifier.

func (VerifierFake) IsHuman

func (r VerifierFake) IsHuman(recaptchaResponse string) (bool, error)

IsHuman checks whether the request is sent by a human user.

type VerifyResponse

type VerifyResponse struct {
	Success       bool    `json:"success"`
	ChallengeTime string  `json:"challenge_ts"`
	Hostname      string  `json:"hostname"`
	Score         float32 `json:"score"`
	Action        string  `json:"action"`
}

VerifyResponse represents the JSON response received from ReCaptcha Verify API.

Jump to

Keyboard shortcuts

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