Package openid :: Package store :: Module nonce
[frames] | no frames]

Module nonce

source code

Functions [hide private]
(int, str) split(nonce_string)
Extract a timestamp from the given nonce string
bool checkTimestamp(nonce_string, allowed_skew=60* 60* 5, now=None)
Is the timestamp that is part of the specified nonce string within the allowed clock-skew of the current time?
str mkNonce(when=None)
Generate a nonce with the current timestamp

Function Details [hide private]

split(nonce_string)

source code 

Extract a timestamp from the given nonce string
Parameters:
  • nonce_string (str) - the nonce from which to extract the timestamp
Returns: (int, str)
A pair of a Unix timestamp and the salt characters
Raises:
  • ValueError - if the nonce does not start with a correctly formatted time string

checkTimestamp(nonce_string, allowed_skew=60* 60* 5, now=None)

source code 

Is the timestamp that is part of the specified nonce string within the allowed clock-skew of the current time?
Parameters:
  • nonce_string (str) - The nonce that is being checked
  • allowed_skew (int) - How many seconds should be allowed for completing the request, allowing for clock skew.
  • now (int) - The current time, as a Unix timestamp
Returns: bool
Whether the timestamp is correctly formatted and within the allowed skew of the current time.

mkNonce(when=None)

source code 

Generate a nonce with the current timestamp
Parameters:
  • when (int) - Unix timestamp representing the issue time of the nonce. Defaults to the current time.
Returns: str
A string that should be usable as a one-way nonce

See Also: time