Skip to content

Commit 858b5a3

Browse files
committed
feat: add debug logging to identity resolver, downgrade git2 to 0.19.0
1 parent de97ba4 commit 858b5a3

14 files changed

Lines changed: 107 additions & 56 deletions

File tree

Cargo.lock

Lines changed: 7 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ ring = "0.17.14"
3737
base64 = "0.22.1"
3838
thiserror = "2"
3939
uuid = { version = "1", features = ["v4"] }
40-
git2 = "0.20.4"
40+
git2 = { version = "0.19.0", default-features = false, features = ["vendored-libgit2"] }
4141
parking_lot = "0.12"
4242
schemars = "0.8"
4343
subtle = "2.6"

crates/auths-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ tokio = { version = "1", features = ["rt-multi-thread", "macros", "time"] }
4747
ring.workspace = true
4848
base64.workspace = true
4949
bs58 = "0.5.1"
50-
git2 = "0.20.4"
50+
git2.workspace = true
5151
dirs = "6.0.0"
5252
chrono = "0.4.40"
5353
jsonschema = { version = "0.42.2", default-features = false }

crates/auths-id/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ bs58 = "0.5.1"
2929
chrono = { version = "0.4.40", features = ["serde"] }
3030
der = "0.8.0"
3131
dirs = { version = "6.0.0", optional = true }
32-
git2 = { version = "0.19.0", optional = true }
32+
git2 = { workspace = true, optional = true }
3333
hex = { version = "0.4.3", features = ["serde"] }
3434
json-canon.workspace = true
3535
jsonschema = { version = "0.42.2", default-features = false }

crates/auths-index/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ log = "0.4"
1919
thiserror.workspace = true
2020
serde = { version = "1", features = ["derive"] }
2121
serde_json = "1"
22-
git2 = "0.20.4"
22+
git2.workspace = true
2323

2424
[dev-dependencies]
2525
tempfile = "3"

crates/auths-infra-git/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ homepage.workspace = true
1414
auths-core = { workspace = true }
1515
auths-sdk = { workspace = true }
1616
auths-verifier = { workspace = true, features = ["native"] }
17-
git2 = "0.20.4"
17+
git2.workspace = true
1818
thiserror.workspace = true
1919
chrono = "0.4"
2020
log = "0.4"

crates/auths-radicle/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ thiserror.workspace = true
4040
auths-crypto = { workspace = true, optional = true }
4141
auths-id = { workspace = true, optional = true }
4242
chrono = { version = "0.4", features = ["serde"], optional = true }
43-
git2 = { version = "0.19.0", optional = true }
43+
git2 = { workspace = true, optional = true }
4444
ring = { workspace = true, optional = true }
4545

4646
# WASM-only

crates/auths-radicle/src/identity.rs

Lines changed: 84 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,32 @@ impl RadicleIdentityResolver {
321321
/// at `v1/devices/{shard}/{sanitized_did}/attestation.json`.
322322
fn find_controller_for_device(&self, device_did: &Did) -> Option<Did> {
323323
let id_path = self.identity_repo_path.as_ref().unwrap_or(&self.repo_path);
324-
let repo = Repository::open(id_path).ok()?;
325-
let att = self.read_device_attestation(&repo, device_did)?;
326-
att.issuer.to_string().parse::<Did>().ok()
324+
eprintln!(
325+
"[auths-debug] find_controller_for_device: id_path={}",
326+
id_path.display()
327+
);
328+
let repo = match Repository::open(id_path) {
329+
Ok(r) => r,
330+
Err(e) => {
331+
eprintln!("[auths-debug] Repository::open failed: {e}");
332+
return None;
333+
}
334+
};
335+
eprintln!("[auths-debug] Repository opened successfully");
336+
let att = match self.read_device_attestation(&repo, device_did) {
337+
Some(a) => a,
338+
None => {
339+
eprintln!("[auths-debug] read_device_attestation returned None");
340+
return None;
341+
}
342+
};
343+
eprintln!("[auths-debug] attestation found, issuer={}", att.issuer);
344+
let result = att.issuer.to_string().parse::<Did>().ok();
345+
eprintln!(
346+
"[auths-debug] parsed issuer DID: {:?}",
347+
result.as_ref().map(|d| d.to_string())
348+
);
349+
result
327350
}
328351

329352
/// Scans the packed registry for all devices with attestations.
@@ -388,28 +411,76 @@ impl RadicleIdentityResolver {
388411
repo: &Repository,
389412
device_did: &Did,
390413
) -> Option<auths_verifier::core::Attestation> {
391-
let registry_tree = self.registry_tree(repo)?;
414+
let registry_tree = match self.registry_tree(repo) {
415+
Some(t) => t,
416+
None => {
417+
eprintln!("[auths-debug] registry_tree returned None");
418+
return None;
419+
}
420+
};
392421
let sanitized = device_did.to_string().replace(':', "_");
393-
let key_part = sanitized.strip_prefix("did_key_")?;
422+
let key_part = match sanitized.strip_prefix("did_key_") {
423+
Some(k) => k,
424+
None => {
425+
eprintln!("[auths-debug] strip_prefix(did_key_) failed for: {sanitized}");
426+
return None;
427+
}
428+
};
394429
if key_part.len() < 4 {
430+
eprintln!("[auths-debug] key_part too short: {key_part}");
395431
return None;
396432
}
397433
let s1 = &key_part[..2];
398434
let s2 = &key_part[2..4];
399435
let att_path = format!("v1/devices/{s1}/{s2}/{sanitized}/attestation.json");
436+
eprintln!("[auths-debug] looking up att_path: {att_path}");
400437

401-
let entry = registry_tree
402-
.get_path(std::path::Path::new(&att_path))
403-
.ok()?;
404-
let blob = repo.find_blob(entry.id()).ok()?;
405-
serde_json::from_slice(blob.content()).ok()
438+
let entry = match registry_tree.get_path(std::path::Path::new(&att_path)) {
439+
Ok(e) => e,
440+
Err(e) => {
441+
eprintln!("[auths-debug] tree.get_path failed: {e}");
442+
return None;
443+
}
444+
};
445+
let blob = match repo.find_blob(entry.id()) {
446+
Ok(b) => b,
447+
Err(e) => {
448+
eprintln!("[auths-debug] find_blob failed: {e}");
449+
return None;
450+
}
451+
};
452+
match serde_json::from_slice(blob.content()) {
453+
Ok(att) => Some(att),
454+
Err(e) => {
455+
eprintln!("[auths-debug] serde_json::from_slice failed: {e}");
456+
None
457+
}
458+
}
406459
}
407460

408461
/// Returns the root tree at `refs/auths/registry`.
409462
fn registry_tree<'r>(&self, repo: &'r Repository) -> Option<git2::Tree<'r>> {
410-
let reference = repo.find_reference(REGISTRY_REF).ok()?;
411-
let commit = reference.peel_to_commit().ok()?;
412-
commit.tree().ok()
463+
let reference = match repo.find_reference(REGISTRY_REF) {
464+
Ok(r) => r,
465+
Err(e) => {
466+
eprintln!("[auths-debug] find_reference({REGISTRY_REF}) failed: {e}");
467+
return None;
468+
}
469+
};
470+
let commit = match reference.peel_to_commit() {
471+
Ok(c) => c,
472+
Err(e) => {
473+
eprintln!("[auths-debug] peel_to_commit failed: {e}");
474+
return None;
475+
}
476+
};
477+
match commit.tree() {
478+
Ok(t) => Some(t),
479+
Err(e) => {
480+
eprintln!("[auths-debug] commit.tree() failed: {e}");
481+
None
482+
}
483+
}
413484
}
414485

415486
/// Reads KEL events by walking the commit chain from the given commit.

crates/auths-radicle/src/storage.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ impl AuthsStorage for GitRadicleStorage {
349349
}
350350

351351
#[cfg(test)]
352+
#[allow(clippy::unwrap_used, clippy::disallowed_methods)]
352353
mod tests {
353354
use super::*;
354355
use auths_id::keri::KeriSequence;

crates/auths-radicle/src/verify.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,12 @@ impl<S: AuthsStorage> RadicleAuthsBridge for DefaultBridge<S> {
267267
};
268268

269269
// Step 6: Evaluate policy (revocation, expiry)
270-
let decision = evaluate_compiled(&attestation, &self.policy, request.now)
271-
.map_err(|e| BridgeError::PolicyEvaluation {
270+
let decision = evaluate_compiled(&attestation, &self.policy, request.now).map_err(|e| {
271+
BridgeError::PolicyEvaluation {
272272
did: IdentityDID::new(identity_did.to_string()),
273273
reason: e.to_string(),
274-
})?;
274+
}
275+
})?;
275276

276277
// Step 7: Capability check
277278
if let Some(required_cap) = request.required_capability
@@ -457,6 +458,7 @@ pub fn meets_threshold(
457458
}
458459

459460
#[cfg(test)]
461+
#[allow(clippy::unwrap_used, clippy::disallowed_methods)]
460462
mod tests {
461463
use super::*;
462464
use auths_verifier::IdentityDID;

0 commit comments

Comments
 (0)