Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCaptchaFailed = fmt.Errorf("captcha failed")
Functions ¶
This section is empty.
Types ¶
type CaptchaService ¶
type CaptchaService interface {
VerifyCaptcha(token string, ip string) (VerifyCaptchaResponse, error)
}
type GoogleRecaptchaService ¶
type GoogleRecaptchaService struct {
CaptchaSecret string
HttpClient restclient.IHTTPClient
}
func NewGoogleRecaptchaService ¶
func NewGoogleRecaptchaService(config GoogleRecaptchaServiceConfig) *GoogleRecaptchaService
NewGoogleRecaptchaService creates a new Captcha service that uses Google Recaptcha
func (*GoogleRecaptchaService) VerifyCaptcha ¶
func (s *GoogleRecaptchaService) VerifyCaptcha(token string, ip string) (VerifyCaptchaResponse, error)
VerifyCaptcha verifies the captcha request with the provider and returns a response
type GoogleRecaptchaServiceConfig ¶
type GoogleRecaptchaServiceConfig struct {
CaptchaSecret string
}
type VerifyCaptchaRequest ¶
type VerifyCaptchaRequest struct {
Secret string `json:"secret"`
Token string `json:"response"`
RemoteIP string `json:"remoteip"`
}
func (VerifyCaptchaRequest) ToJSON ¶
func (r VerifyCaptchaRequest) ToJSON() []byte
func (VerifyCaptchaRequest) ToQueryString ¶
func (r VerifyCaptchaRequest) ToQueryString() []byte
type VerifyCaptchaResponse ¶
type VerifyCaptchaResponse struct {
Success bool `json:"success"`
ChallengeTimestamp time.Time `json:"challenge_ts"`
HostName string `json:"hostname"`
ErrorCodes []string `json:"error-codes"`
}
func NewVerifyCaptchaResponseFromReader ¶
func NewVerifyCaptchaResponseFromReader(reader io.Reader) (VerifyCaptchaResponse, error)
Click to show internal directories.
Click to hide internal directories.