You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-6Lines changed: 12 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,13 +32,14 @@ Classes
32
32
### ExpressBrute(store, options)
33
33
-`store` An instance of `ExpressBrute.MemoryStore` or `ExpressBrute.MemcachedStore`
34
34
-`options`
35
-
- `freeRetries` The number of retires the user has before they need to start waiting (default: 2)
36
-
- `minWait` The initial wait time (in milliseconds) after the user runs out of retries (default: 500 milliseconds)
37
-
- `maxWait` The maximum amount of time (in milliseconds) between requests the user needs to wait (default: 15 minutes). The wait for a given request is determined by adding the time the user needed to wait for the previous two requests.
38
-
- `lifetime` The length of time (in seconds since the last request) to remember the number of requests that have been made by an IP. By default it will be set to `maxWait * the number of attempts before you hit maxWait` to discourage simply waiting for the lifetime to expire before resuming an attack. With default values this is about 6 hours.
35
+
- `freeRetries` The number of retires the user has before they need to start waiting (default: 2)
36
+
- `minWait` The initial wait time (in milliseconds) after the user runs out of retries (default: 500 milliseconds)
37
+
- `maxWait` The maximum amount of time (in milliseconds) between requests the user needs to wait (default: 15 minutes). The wait for a given request is determined by adding the time the user needed to wait for the previous two requests.
38
+
- `lifetime` The length of time (in seconds since the last request) to remember the number of requests that have been made by an IP. By default it will be set to `maxWait * the number of attempts before you hit maxWait` to discourage simply waiting for the lifetime to expire before resuming an attack. With default values this is about 6 hours.
39
39
- `failCallback` gets called with (`req`, `resp`, `next`, `nextValidRequestDate`) when a request is rejected (default: ExpressBrute.FailForbidden)
40
-
- `proxyDepth` Specifies how many levels of the `X-Forwarded-For` header to trust. If your web server is behind a CDN and/or load balancer you'll need to set this to however many levels of proxying it's behind to get a valid IP. Setting this too high allows attackers to get around brute force protection by spoofing the `X-Forwarded-For` header, so don't set it higher than you need to (default: 0)
41
-
- `attachResetToRequest` Specify whether or not a simplified reset method should be attached at `req.brute.reset`. The simplified method takes only a callback, and resets all `ExpressBrute` middleware that was called on the current request. If multiple instances of `ExpressBrute` have middleware on the same request, only those with `attachResetToRequest` set to true will be reset (default: true)
40
+
- `proxyDepth` Specifies how many levels of the `X-Forwarded-For` header to trust. If your web server is behind a CDN and/or load balancer you'll need to set this to however many levels of proxying it's behind to get a valid IP. Setting this too high allows attackers to get around brute force protection by spoofing the `X-Forwarded-For` header, so don't set it higher than you need to (default: 0)
41
+
- `attachResetToRequest` Specify whether or not a simplified reset method should be attached at `req.brute.reset`. The simplified method takes only a callback, and resets all `ExpressBrute` middleware that was called on the current request. If multiple instances of `ExpressBrute` have middleware on the same request, only those with `attachResetToRequest` set to true will be reset (default: true)
42
+
- `refreshTimeoutOnRequest` Defines whether the remaining `lifetime` of a counter should be based on the time since the last request (true) of the time since the first request (false). Useful for allowing limits over fixed periods of time, for example a limited number of requests per day. (Default: true)
42
43
43
44
### ExpressBrute.MemoryStore()
44
45
An in-memory store for persisting request counts. Don't use this in production.
@@ -111,6 +112,7 @@ var globalBruteforce = new ExpressBrute(store, {
111
112
freeRetries:1000,
112
113
proxyDepth:1,
113
114
attachResetToRequest:false,
115
+
refreshTimeoutOnRequest:false,
114
116
winWait:25*60*60*1000, // 1 day 1 hour (should never reach this wait time)
115
117
maxWait:25*60*60*1000, // 1 day 1 hour (should never reach this wait time)
116
118
lifetime:24*60*60*1000, // 1 day
@@ -141,6 +143,10 @@ app.post('/auth',
141
143
142
144
Changelog
143
145
---------
146
+
### v0.4.1
147
+
* NEW: `refreshTimeoutOnRequest` option that allows you to prevent the remaining `lifetime` for a timer from being reset on each request (useful for implementing limits for set time frames, e.g. requests per day)
148
+
* BUG: Lifetimes were not previously getting extended properly for instances of `ExpressBrute.MemoryStore`
149
+
144
150
### v0.4.0
145
151
* NEW: `attachResetToRequest` parameter that lets you prevent the request object being decorated
146
152
* NEW: `failCallback` can be overriden by `getMiddleware`
0 commit comments