MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / delegation_header

Function delegation_header

atomic-remote/src/auth/mod.rs:458–475  ·  view source on GitHub ↗

The encoded certificate an agent identity should present, if any. `None` for a human — they have no certificate and need none. `None` too when an agent has no usable certificate, because the resulting 401 from the server ("carries no certificate") names the problem better than anything we could raise here, and a read against a public project may not need one at all.

(store: &IdentityStore, identity: &Identity, server: &str)

Source from the content-addressed store, hash-verified

456/// could raise here, and a read against a public project may not need one at
457/// all.
458fn delegation_header(store: &IdentityStore, identity: &Identity, server: &str) -> Option<String> {
459 if !identity.identity_type.is_delegated() {
460 return None;
461 }
462
463 match crate::auth::delegation::active_for(store, identity, Some(server)) {
464 Ok(resolved) => Some(atomic_canonical::delegation::encode_for_transport(
465 &resolved.document,
466 )),
467 Err(e) => {
468 log::debug!(
469 "No usable delegation for agent '{}' against {server}: {e}",
470 identity.name
471 );
472 None
473 }
474 }
475}
476
477/// What went wrong (if anything) when checking for usable push credentials.
478///

Callers 1

attach_identityFunction · 0.85

Calls 3

active_forFunction · 0.85
encode_for_transportFunction · 0.85
is_delegatedMethod · 0.80

Tested by

no test coverage detected