feat: Rate limit API token requests
600 per minute per token, in the Redis that sessions already require. Cookie sessions are untouched. A Redis failure falls through rather than refusing traffic — it is already a larger problem and should not become a second outage.
This commit is contained in:
@@ -59,6 +59,11 @@ func PingRedis(ctx context.Context) error {
|
||||
return rdb.Ping(ctx).Err()
|
||||
}
|
||||
|
||||
// Redis exposes the session client for callers that need a counter rather than
|
||||
// a session. There is one Redis in this deployment and adding a second client
|
||||
// would double the connection pool for no reason.
|
||||
func Redis() *redis.Client { return rdb }
|
||||
|
||||
func randomHex(n int) (string, error) {
|
||||
b := make([]byte, n)
|
||||
if _, err := rand.Read(b); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user