MCPcopy
hub / github.com/tornadoweb/tornado / decode_signed_value

Function decode_signed_value

tornado/web.py:3671–3699  ·  view source on GitHub ↗
(
    secret: _CookieSecretTypes,
    name: str,
    value: Union[None, str, bytes],
    max_age_days: float = 31,
    clock: Optional[Callable[[], float]] = None,
    min_version: Optional[int] = None,
)

Source from the content-addressed store, hash-verified

3669
3670
3671def decode_signed_value(
3672 secret: _CookieSecretTypes,
3673 name: str,
3674 value: Union[None, str, bytes],
3675 max_age_days: float = 31,
3676 clock: Optional[Callable[[], float]] = None,
3677 min_version: Optional[int] = None,
3678) -> Optional[bytes]:
3679 if clock is None:
3680 clock = time.time
3681 if min_version is None:
3682 min_version = DEFAULT_SIGNED_VALUE_MIN_VERSION
3683 if min_version > 2:
3684 raise ValueError("Unsupported min_version %d" % min_version)
3685 if not value:
3686 return None
3687
3688 value = utf8(value)
3689 version = _get_version(value)
3690
3691 if version < min_version:
3692 return None
3693 if version == 1:
3694 assert not isinstance(secret, dict)
3695 return _decode_signed_value_v1(secret, name, value, max_age_days, clock)
3696 elif version == 2:
3697 return _decode_signed_value_v2(secret, name, value, max_age_days, clock)
3698 else:
3699 return None
3700
3701
3702def _decode_signed_value_v1(

Callers 9

test_known_valuesMethod · 0.90
test_name_swapMethod · 0.90
test_expiredMethod · 0.90
validateMethod · 0.90
test_non_asciiMethod · 0.90
get_signed_cookieMethod · 0.85

Calls 4

utf8Function · 0.90
_get_versionFunction · 0.85
_decode_signed_value_v1Function · 0.85
_decode_signed_value_v2Function · 0.85

Tested by 8

test_known_valuesMethod · 0.72
test_name_swapMethod · 0.72
test_expiredMethod · 0.72
validateMethod · 0.72
test_non_asciiMethod · 0.72