Parameters: |
- storage_client (object) –
Object used to actually access the storage.
At a minimum, the storage should have two methods, get(key) and set(key, value),
where both key and value are strings.
A typical example is an memcache.Client instance.
- config (dict) –
A dictionary containing storage parameters (dictionary keys are the parameter name
and dictionary values are the parameter value).
Allows defining the format of the storage keys, and the expiration times for each type of counter.
You can ommit all dictionary keys except for the authenticator_key parameter,
the missing keys will be taken from the default configuration.
Structure:
Key |
Type |
Description |
keys_prefix |
string |
Prefix for all storage keys. |
counter_keys_formats |
dictionary with string values |
Formats for each type of counter. |
total_format |
string |
Total format of the storage keys, including the prefix,
the context and the specific counter key. |
expiration_times |
dictionary with integer values |
Expiration time for each type of counter, in seconds. |
authenticator_key |
string |
Authenticator key as generated by generate_authenticator_key(). |
Default configuration:
{
'keys_prefix': '',
'counter_keys_formats': {
'ip': 'ip:{ip}',
'user': 'user:{user}',
'pwd': 'pwd:{pwd}',
'ip_user': 'ip_user:{ip}{user}',
'ip_pwd': 'ip_pwd:{ip}{pwd}',
},
'total_format': '{keys_prefix}:{ctx}:{counter_key}',
'expiration_times': {
'ip': 3600,
'user': 3 * 3600,
'pwd': 3 * 3600,
'ip_user': 3 * 3600,
'ip_pwd': 3 * 3600,
},
}
|