For multi-servers in production:
Proposed usage:
e := echo.New()
abuseStore := store.NewRedisCounter("localhost:XXXX")
// Instant-ban on sensitive files, warn on API spam
e.Use(abuse.New(abuse.Config{
Store: abuseStore,
Threshold: 100,
Rules: []abuse.Rule{
// immediate ban for ANY attempt on .env
{Path: "/.env", Score: 100},
// heavy score only for POST requests to login (brute force protection)
{Path: "/api/v1/login", Method: "POST", Score: 20},
// light score for general API exploration
{Path: "/api/v1/*", Method: "GET", Score: 2},
{Path: "/api/v1/users", Method: "PUT", Score: 20},
},
}))
For multi-servers in production:
Proposed usage: