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
tokenequals current or past value (constant-time on equal length).token是否等于当前或宽限值(等长时恒定时间比较)。 - refresh_
token - Refresh: move current → past, CAS-write a new current. 刷新:当前值写入 past,再用 CAS 写入新的当前值。