MCPcopy Create free account
hub / github.com/EasyIME/PIME / decode_signed_value

Function decode_signed_value

python/python3/tornado/web.py:3470–3498  ·  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

3468
3469
3470def decode_signed_value(
3471 secret: _CookieSecretTypes,
3472 name: str,
3473 value: Union[None, str, bytes],
3474 max_age_days: float = 31,
3475 clock: Optional[Callable[[], float]] = None,
3476 min_version: Optional[int] = None,
3477) -> Optional[bytes]:
3478 if clock is None:
3479 clock = time.time
3480 if min_version is None:
3481 min_version = DEFAULT_SIGNED_VALUE_MIN_VERSION
3482 if min_version > 2:
3483 raise ValueError("Unsupported min_version %d" % min_version)
3484 if not value:
3485 return None
3486
3487 value = utf8(value)
3488 version = _get_version(value)
3489
3490 if version < min_version:
3491 return None
3492 if version == 1:
3493 assert not isinstance(secret, dict)
3494 return _decode_signed_value_v1(secret, name, value, max_age_days, clock)
3495 elif version == 2:
3496 return _decode_signed_value_v2(secret, name, value, max_age_days, clock)
3497 else:
3498 return None
3499
3500
3501def _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_secure_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