MCPcopy
hub / github.com/django/django / unsign

Method unsign

django/core/signing.py:275–290  ·  view source on GitHub ↗

Retrieve original value and check it wasn't signed more than max_age seconds ago.

(self, value, max_age=None)

Source from the content-addressed store, hash-verified

273 return super().sign(value)
274
275 def unsign(self, value, max_age=None):
276 """
277 Retrieve original value and check it wasn't signed more
278 than max_age seconds ago.
279 """
280 result = super().unsign(value)
281 value, timestamp = result.rsplit(self.sep, 1)
282 timestamp = b62_decode(timestamp)
283 if max_age is not None:
284 if isinstance(max_age, datetime.timedelta):
285 max_age = max_age.total_seconds()
286 # Check timestamp is not older than max_age
287 age = time.time() - timestamp
288 if age > max_age:
289 raise SignatureExpired("Signature age %s > %s seconds" % (age, max_age))
290 return value

Callers 1

test_timestamp_signerMethod · 0.95

Calls 4

b62_decodeFunction · 0.85
SignatureExpiredClass · 0.85
timeMethod · 0.80
unsignMethod · 0.45

Tested by 1

test_timestamp_signerMethod · 0.76