gws.base.auth.throttle¶
Authentication throttle.
Source code: gws.base.auth.throttle
Module Contents¶
- class gws.base.auth.throttle.Config(*args, **kwargs)¶
Bases:
gws.ConfigBlocking of repeated failed authentication attempts.
- blockTime: gws.Duration = '15m'¶
How long to block once the limit is reached.
- maxAttemptsPerUser: int = 0¶
Failed attempts per login name from any address before blocking, 0 for no limit.
- windowTime: gws.Duration = '10m'¶
Time span in which failed attempts are counted.
- class gws.base.auth.throttle.Object¶
Bases:
gws.NodeAuthentication throttle.
Counts failed authentication attempts per remote address and, optionally, per login name, and blocks further attempts once a limit is reached.
- table = 'throttle'¶
Name of the database table.
- blocked_for(req: gws.WebRequester, method: gws.AuthMethod, credentials: gws.Data) int¶
Return how long an authentication attempt remains blocked.
- Parameters:
req – The web request, provides the remote address.
method – The authentication method.
credentials – The credentials, provide the login name as
username.
- Returns:
The remaining blocking time in seconds, 0 if the attempt is allowed.
- cleanup()¶
Remove the counts whose window has elapsed and which hold no active block.
- configure()¶
Configuration hook.
Called when the node is initialized. Raising an exception here aborts the creation of the node.
- register(ok: bool, req: gws.WebRequester, method: gws.AuthMethod, credentials: gws.Data)¶
Register the outcome of an authentication attempt.
A success removes the counts for the address and the login name. A failure increments them and starts a block once a limit is reached.
- Parameters:
ok – Whether the attempt was successful.
req – The web request, provides the remote address.
method – The authentication method.
credentials – The credentials, provide the login name as
username.