MCPcopy
hub / github.com/opendevops-cn/opendevops / decode_signed_value

Function decode_signed_value

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

Source from the content-addressed store, hash-verified

3434
3435
3436def decode_signed_value(
3437 secret: _CookieSecretTypes,
3438 name: str,
3439 value: Union[None, str, bytes],
3440 max_age_days: int = 31,
3441 clock: Callable[[], float] = None,
3442 min_version: int = None,
3443) -> Optional[bytes]:
3444 if clock is None:
3445 clock = time.time
3446 if min_version is None:
3447 min_version = DEFAULT_SIGNED_VALUE_MIN_VERSION
3448 if min_version > 2:
3449 raise ValueError("Unsupported min_version %d" % min_version)
3450 if not value:
3451 return None
3452
3453 value = utf8(value)
3454 version = _get_version(value)
3455
3456 if version < min_version:
3457 return None
3458 if version == 1:
3459 assert not isinstance(secret, dict)
3460 return _decode_signed_value_v1(secret, name, value, max_age_days, clock)
3461 elif version == 2:
3462 return _decode_signed_value_v2(secret, name, value, max_age_days, clock)
3463 else:
3464 return None
3465
3466
3467def _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