OpenQuizz
Une application de gestion des contenus pédagogiques
TimestampSigner Class Reference
Inheritance diagram for TimestampSigner:
Collaboration diagram for TimestampSigner:

Public Member Functions

def get_timestamp (self)
 
def timestamp_to_datetime (self, ts)
 
def sign (self, value)
 
def unsign (self, value, max_age=None, return_timestamp=False)
 
def validate (self, signed_value, max_age=None)
 
- Public Member Functions inherited from Signer
def __init__ (self, secret_key, salt=None, sep=".", key_derivation=None, digest_method=None, algorithm=None)
 
def derive_key (self)
 
def get_signature (self, value)
 
def verify_signature (self, value, sig)
 
def unsign (self, signed_value)
 
def validate (self, signed_value)
 

Additional Inherited Members

- Data Fields inherited from Signer
 secret_key
 
 sep
 
 salt
 
 key_derivation
 
 digest_method
 
 algorithm
 
- Static Public Attributes inherited from Signer
 default_digest_method
 
 default_key_derivation
 

Detailed Description

Works like the regular :class:`.Signer` but also records the time
of the signing and can be used to expire signatures. The
:meth:`unsign` method can raise :exc:`.SignatureExpired` if the
unsigning failed because the signature is expired.

Member Function Documentation

◆ get_timestamp()

def get_timestamp (   self)
Returns the current timestamp. The function must return an
integer.

◆ sign()

def sign (   self,
  value 
)
Signs the given string and also attaches time information.

Reimplemented from Signer.

◆ timestamp_to_datetime()

def timestamp_to_datetime (   self,
  ts 
)
Used to convert the timestamp from :meth:`get_timestamp` into
a datetime object.

◆ unsign()

def unsign (   self,
  value,
  max_age = None,
  return_timestamp = False 
)
Works like the regular :meth:`.Signer.unsign` but can also
validate the time. See the base docstring of the class for
the general behavior. If ``return_timestamp`` is ``True`` the
timestamp of the signature will be returned as a naive
:class:`datetime.datetime` object in UTC.

◆ validate()

def validate (   self,
  signed_value,
  max_age = None 
)
Only validates the given signed value. Returns ``True`` if
the signature exists and is valid.

The documentation for this class was generated from the following file: