Feat/ucan chain validation#19
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR adds optional UCAN (User Controlled Authorization Network) chain validation to authenticated routes and strengthens UCAN verification by enforcing not-before validity and capability attenuation rules.
Changes:
- Add
require_ucan_chainmiddleware (stateful) to multiple signed write-route groups. - Extend
gitlawb_core::ucanverification withnbfchecks, audience checking, and capability attenuation enforcement. - Add unit tests for UCAN chain validation, not-before handling, audience mismatch, and attenuation behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| crates/gitlawb-node/src/server.rs | Adds UCAN-chain validation middleware to various routers alongside HTTP Signature auth. |
| crates/gitlawb-node/src/auth/mod.rs | Implements UCAN header validation middleware + UCAN chain validator and tests. |
| crates/gitlawb-core/src/ucan.rs | Adds audience/nbf helpers and enforces capability attenuation during chain verification + tests. |
Comments suppressed due to low confidence (1)
crates/gitlawb-core/src/ucan.rs:1
- The attenuation check is performed inside the loop over
self.payload.prf, which means every proof must individually cover every delegated capability. Ifprfcan contain multiple proofs (e.g., combining rights), this will incorrectly reject valid tokens where different proofs cover different capabilities. A more correct approach is to validate each proof’s signature/chain and then check that each delegated capability is covered by at least one valid proof (i.e., union of proof capabilities), or explicitly restrict UCANs to a single proof and return a clear error when multiple proofs are present.
//! UCAN (User Controlled Authorization Networks) — capability token types.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR Review Updates SummaryAll 5 review comments from the Copilot audit have been fully addressed and verified locally. The changes compile cleanly, format successfully, and pass all clippy checks and workspace unit/integration tests with zero warnings:
|
Test Results
gitlawb-core
cargo test -p gitlawb-coregitlawb-node
cargo test -p gitlawb-nodeNotes