Class StatelessNonceStore
source code
This is a stateless nonce storage that cannot check the usage count
for a nonce and thus cannot protect against replay attacks. It however
can make it difficult by posing a timeout on nonces and making it
difficult to forge nonces.
This nonce store is usable with scgi.forkpool.
>>> s = StatelessNonceStore()
>>> n = s.newnonce()
>>> s.checknonce("spam")
False
>>> s.checknonce(n)
True
>>> s.checknonce(n)
True
>>> s.checknonce(n.rsplit(':', 1)[0] + "bad hash")
False
|
|
|
|
str
|
|
|
bool
|
checknonce(self,
nonce,
count=1,
ident=None)
Do a check for whether the provided string is a nonce and increase
usage count on returning True. |
source code
|
|
__init__(self,
maxage=300,
secret=None)
(Constructor)
| source code
|
- Parameters:
maxage (int) - is the number of seconds a nonce may be valid. Choosing a large
value may result in more memory usage whereas a smaller value
results in more requests. Defaults to 5 minutes.
secret (str) - if not given, a secret is generated and is therefore shared after
forks. Knowing this secret permits creating nonces.
- Overrides:
NonceStoreBase.__init__
|
|
Generates a new nonce string.
- Parameters:
ident (None or str) - is an identifier to be associated with this nonce
- Returns: str
- Overrides:
NonceStoreBase.newnonce
|
checknonce(self,
nonce,
count=1,
ident=None)
| source code
|
Do a check for whether the provided string is a nonce and increase
usage count on returning True.
- Parameters:
count (int) - indicates how often the nonce has been used (including this
check)
ident (None or str) - it is also checked that the nonce was associated to this
identifier when given
nonce (str)
- Returns: bool
- Overrides:
NonceStoreBase.checknonce
|