Repository navigation
Conversation
Split the challenge.rs monolith into a challenge/ module: mod.rs holds the async Challenger trait and the shared build_challenge_json/verify_jwt/rs384_sign helpers, ephemeral.rs holds an in-memory-key EphemeralJwtChallenger, and fs.rs (feature-gated) holds the on-disk-key FsJwtChallenger. AttestationService gains a challenger field wired in new(), the challenge_key_path() accessor becomes challenger(), and the grpc/restful bin handlers verify via challenger() instead of the old free function. Signed-off-by: Kun Lai <laikun@linux.alibaba.com>
Add a third Challenger impl that mints a purely local random nonce with no JWT and no cryptographic key: generate_challenge stores the full challenge JSON string in a Mutex<HashSet> and returns it, and verify removes it from the set on success so each token is single-use and replays are rejected. Freshness is one-time set membership (stronger single-instance guarantee than the JWT exp window) at the cost of being single-process and unsuitable for multi-replica deployments. Signed-off-by: Kun Lai <laikun@linux.alibaba.com>
The challenge_token verification was duplicated in the grpc and restful bin handlers before runtime data reached the service. Move it into AttestationService::evaluate(), where each verification request is iterated, so both frontends verify the challenge_token through a single code path. Signed-off-by: Kun Lai <laikun@linux.alibaba.com>
Collect challenge_token values from all verification requests into a HashSet and verify each unique token once, rather than verifying per-request. This avoids consuming a single-use token multiple times when the same token appears across requests. Signed-off-by: Kun Lai <laikun@linux.alibaba.com>
|
@imlk0 ,您好,您的请求已接收,请耐心等待结果。 |
|
@imlk0 ,您好,未检测到有镜像需要构建,如需重新检测请评论 /start 。 |
jialez0
left a comment
There was a problem hiding this comment.
以下是本次 review 中需要确认和修正的四个问题。
| /// sources `challenge_token` from `extra-params.jwt`; freshness is the | ||
| /// JWT signature + `exp` (multi-replica friendly). | ||
| /// - [`LocalNonceChallenger`] returns just `{"nonce": <b64>}` — the nonce | ||
| /// itself is the single-use token, so the client echoes the `nonce` back as |
There was a problem hiding this comment.
这里的接口说明与实现不一致:文档要求客户端回传 nonce,但 LocalNonceChallenger 实际将完整 challenge JSON 存入集合,并要求完整 JSON 原样作为 challenge_token 回传。按此文档实现会验证失败,请统一 token 格式,并补充端到端测试。
| self.issued | ||
| .lock() | ||
| .expect("issued-nonce mutex poisoned") | ||
| .insert(challenge_json.clone()); |
There was a problem hiding this comment.
issued 当前没有 TTL、容量上限或清理机制,未消费的 challenge 会一直有效并持续占用内存。建议存储过期时间,增加惰性/定期清理及最大容量限制。
| .issued | ||
| .lock() | ||
| .expect("issued-nonce mutex poisoned") | ||
| .remove(token); |
There was a problem hiding this comment.
这里在 evidence 和 policy 验证前就 remove token。后续验证失败时客户端无法重试,多 token 请求还可能出现部分消费。请确认是否符合预期;建议设计 reserve/commit/rollback,或采用等价的原子状态管理。
| )] | ||
| InvalidChallengeToken { | ||
| request_index: usize, | ||
| challenge_token: String, |
There was a problem hiding this comment.
这里保存了原始 challenge_token,而 gRPC 通过 {e:?} 返回完整错误链,会把 token 暴露给客户端,也可能进入日志。建议错误中不保存原始 token,或在传输和日志层统一脱敏。
|
Superseded by #221 |
The main purpose of this commit is to add the
Challengertrait, with three implementations:FsJwtChallenger(on-disk key, behavior unchanged)EphemeralJwtChallenger(in-memory key)LocalNonceChallenger(local random nonce, single-use, replay-resistant)It also adds
AttestationService::from_components(), allowing crate integrators to createAttestationServiceinstances directly through this function.Additionally, challenge token verification, previously handled separately by grpc-as and restful-as, is unified into
AttestationService::evaluate().