Skip to main content

Module same_token

Module same_token 

Source
Expand description

Same-Token: shared secret for intra-cluster / gateway-to-service calls. Same-Token:集群内 / 网关到服务 调用使用的共享口令。

Current value plus one previous value (grace window) are both accepted. 当前值与上一次值(宽限期)均视为有效。

Constants§

DEFAULT_HEADER
Default header name. 默认请求头名。

Functions§

check_current_request
Check the Same-Token captured on the current request. 校验当前请求上下文中捕获的 Same-Token。
check_token
Check a raw token string. 校验原始 token 字符串。
get_past_token_nh
Read past Same-Token (grace window). 读取宽限期内的上一次 Same-Token。
get_token
Get current token, creating one if missing. 获取当前 token,不存在则创建。
get_token_nh
Read current Same-Token without creating one. 读取当前 Same-Token(不自动创建)。
is_valid
Whether token equals current or past value (constant-time on equal length). token 是否等于当前或宽限值(等长时恒定时间比较)。
refresh_token
Refresh: move current → past, CAS-write a new current. 刷新:当前值写入 past,再用 CAS 写入新的当前值。