Documentation
¶
Index ¶
- Constants
- func OnRecaptchaVerify() *hook.Hook[*RecaptchaVerifyEvent]
- func RecaptchaEndpointHandler(params *RecaptchaEndpointHandlerParams) apis.HandleFunc
- func RecordListRequestHandlerFunc(params *RequestHandlerParams) func(*core.RecordsListRequestEvent) error
- func RecordRequestHandlerFunc(params *RequestHandlerParams) func(*core.RecordRequestEvent) error
- type EndpointConfig
- type Plugin
- type RecaptchaEndpointHandlerParams
- type RecaptchaEndpointRequestBody
- type RecaptchaVerifyEvent
- type RecaptchaVerifyParams
- type RecaptchaVerifyResult
- type RecordRequestHooksCollectionConfig
- type RecordRequestHooksConfig
- type RequestHandlerParams
- type VerificationError
Constants ¶
View Source
const DefaultRecaptchaVerifyUrl = "https://www.google.com/recaptcha/api/siteverify"
Variables ¶
This section is empty.
Functions ¶
func OnRecaptchaVerify ¶
func OnRecaptchaVerify() *hook.Hook[*RecaptchaVerifyEvent]
func RecaptchaEndpointHandler ¶
func RecaptchaEndpointHandler(params *RecaptchaEndpointHandlerParams) apis.HandleFunc
func RecordListRequestHandlerFunc ¶
func RecordListRequestHandlerFunc(params *RequestHandlerParams) func(*core.RecordsListRequestEvent) error
func RecordRequestHandlerFunc ¶
func RecordRequestHandlerFunc(params *RequestHandlerParams) func(*core.RecordRequestEvent) error
Types ¶
type EndpointConfig ¶
type Plugin ¶
type Plugin struct {
EndpointConfig *EndpointConfig `json:"endpoint"`
RecordRequestHooksConfig *RecordRequestHooksConfig `json:"record_request_hooks"`
// Can be set using an environment variable XPB__RECAPTCHA__SECRET
Secret string `json:"secret" env:"SECRET"`
}
func (*Plugin) Description ¶
Description implements xpb.Plugin.Description interface method.
func (*Plugin) Init ¶
Init implements xpb.Plugin.Init interface method.
func (*Plugin) Name ¶
Name implements xpb.Plugin.Name interface method.
func (*Plugin) Validate ¶
Validate implements validation.Validatable.Validate interface method.
func (*Plugin) Version ¶
Version implements xpb.Plugin.Version interface method.
type RecaptchaEndpointHandlerParams ¶
type RecaptchaEndpointHandlerParams struct {
Secret string
}
type RecaptchaEndpointRequestBody ¶
type RecaptchaEndpointRequestBody struct {
Token string `form:"token" json:"token"`
}
type RecaptchaVerifyEvent ¶
type RecaptchaVerifyParams ¶
type RecaptchaVerifyParams struct {
RemoteIp string `json:"remoteIp"`
Secret string `json:"secret"`
Token string `json:"token"`
VerifyUrl string `json:"verifyUrl"`
}
func (*RecaptchaVerifyParams) Validate ¶
func (params *RecaptchaVerifyParams) Validate() error
type RecaptchaVerifyResult ¶
func VerifyRecaptcha ¶
func VerifyRecaptcha(params *RecaptchaVerifyParams) (*RecaptchaVerifyResult, error)
type RecordRequestHooksCollectionConfig ¶
type RecordRequestHooksCollectionConfig struct {
CollectionName string `json:"collection_name"`
Events []string `json:"events"`
}
func (*RecordRequestHooksCollectionConfig) Validate ¶
func (c *RecordRequestHooksCollectionConfig) Validate() error
Validate implements validation.Validatable.Validate interface method.
type RecordRequestHooksConfig ¶
type RecordRequestHooksConfig struct {
// Defaults to false, meaning feature will be enabled.
Disabled bool `json:"disabled"`
// Defaults to "Recaptcha-Token"
TokenHeaderKey string `json:"token_header_key"`
Collections []*RecordRequestHooksCollectionConfig `json:"collections"`
}
func (*RecordRequestHooksConfig) Validate ¶
func (c *RecordRequestHooksConfig) Validate() error
Validate implements validation.Validatable.Validate interface method.
type RequestHandlerParams ¶
type VerificationError ¶
type VerificationError string
const ( ErrMissingInputSecret VerificationError = "missing-input-secret" ErrInvalidInputSecret VerificationError = "invalid-input-secret" ErrMissingInputResponse VerificationError = "missing-input-response" ErrInvalidInputResponse VerificationError = "invalid-input-response" ErrBadRequest VerificationError = "bad-request" ErrTimoutOrDuplicate VerificationError = "timeout-or-duplicate" )
func (VerificationError) Code ¶
func (err VerificationError) Code() string
func (VerificationError) Error ¶
func (err VerificationError) Error() string
func (*VerificationError) UnmarshalJSON ¶
func (errPtr *VerificationError) UnmarshalJSON(data []byte) error
grecaptcha seems to only ever return one error despite the api suggesting multiple, so to simplify things we reducing it to a single error.
Click to show internal directories.
Click to hide internal directories.