Documentation
¶
Index ¶
- Variables
- func ApplyReCAPTCHA(paths ...string) func(echo.Context) bool
- func HasAuthorization(level int32, scopes ...string) echo.MiddlewareFunc
- func HasAuthorizationWithConfig(config HasAuthorizationConfig, level int32, scopes ...string) echo.MiddlewareFunc
- func ReCAPTCHA() echo.MiddlewareFunc
- func ReCAPTCHAWithConfig(cfg ReCAPTCHAConfig) echo.MiddlewareFunc
- func SkipReCAPTCHA(paths ...string) func(echo.Context) bool
- type HasAuthorizationConfig
- type ReCAPTCHAConfig
- type ReCAPTCHAResponse
- type VerifyReCAPTCHAFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultHasAuthorizationConfig = HasAuthorizationConfig{
JWTContextKey: "user",
AdminLevelClaim: "adm",
}
View Source
var DefaultReCAPTCHAConfig = ReCAPTCHAConfig{ Skipper: defaultSkipper, SecretKey: config.ServiceReCAPTCHASecretKey.GetString(), MinScore: config.ServiceReCAPTCHAMinScore.GetFloat64(), FieldName: config.ServiceReCAPTCHAFieldName.GetString(), }
DefaultReCAPTCHAConfig is the default configuration for the reCAPTCHA middleware
Functions ¶
func ApplyReCAPTCHA ¶ added in v0.0.11
ApplyReCAPTCHA returns a skipper that applies reCAPTCHA verification only to specific paths
func HasAuthorization ¶ added in v0.0.6
func HasAuthorizationWithConfig ¶ added in v0.0.6
func HasAuthorizationWithConfig(config HasAuthorizationConfig, level int32, scopes ...string) echo.MiddlewareFunc
func ReCAPTCHA ¶ added in v0.0.11
func ReCAPTCHA() echo.MiddlewareFunc
ReCAPTCHA returns a middleware that validates Google reCAPTCHA v3 tokens
func ReCAPTCHAWithConfig ¶ added in v0.0.11
func ReCAPTCHAWithConfig(cfg ReCAPTCHAConfig) echo.MiddlewareFunc
ReCAPTCHAWithConfig returns a middleware with config that validates Google reCAPTCHA v3 tokens
func SkipReCAPTCHA ¶ added in v0.0.11
SkipReCAPTCHA returns a skipper that skips reCAPTCHA verification for specific paths
Types ¶
type HasAuthorizationConfig ¶ added in v0.0.6
type ReCAPTCHAConfig ¶ added in v0.0.11
type ReCAPTCHAConfig struct {
// Skipper defines a function to skip middleware
Skipper func(c echo.Context) bool
// SecretKey is the Google reCAPTCHA v3 secret key
SecretKey string
// MinScore is the minimum score threshold (0.0 to 1.0)
MinScore float64
// FieldName is the field name in the JSON payload containing the reCAPTCHA token
FieldName string
}
ReCAPTCHAConfig holds configuration for the reCAPTCHA middleware
type ReCAPTCHAResponse ¶ added in v0.0.11
type ReCAPTCHAResponse struct {
Success bool `json:"success"`
Score float64 `json:"score"`
Action string `json:"action"`
ChallengeTS time.Time `json:"challenge_ts"`
Hostname string `json:"hostname"`
ErrorCodes []string `json:"error-codes,omitempty"`
}
ReCAPTCHAResponse represents the response from Google's reCAPTCHA API
type VerifyReCAPTCHAFunc ¶ added in v0.0.11
type VerifyReCAPTCHAFunc func(token, secretKey string) (*ReCAPTCHAResponse, error)
VerifyReCAPTCHAFunc defines the function signature for reCAPTCHA verification
Click to show internal directories.
Click to hide internal directories.