codetether_agent/a2a/git_credentials/material.rs
1//! Credential material returned by the A2A control plane.
2//!
3//! This module defines the token payload the worker receives when it asks the
4//! server for short-lived Git credentials.
5//!
6//! # Examples
7//!
8//! ```ignore
9//! let creds = GitCredentialMaterial {
10//! username: "x-access-token".to_string(),
11//! password: "secret".to_string(),
12//! expires_at: None,
13//! token_type: "github_app".to_string(),
14//! host: None,
15//! path: None,
16//! };
17//! ```
18
19use std::fmt;
20
21/// Short-lived Git credential material issued by the server.
22///
23/// The host and path fields are optional because Git may already have supplied
24/// them in the original credential-helper request.
25///
26/// The `password` field is redacted in [`Debug`](std::fmt::Debug) output to
27/// prevent accidental credential leakage in logs.
28///
29/// # Examples
30///
31/// ```ignore
32/// assert_eq!(creds.token_type, "github_app");
33/// ```
34#[derive(serde::Deserialize)]
35pub struct GitCredentialMaterial {
36 pub username: String,
37 pub password: String,
38 pub expires_at: Option<String>,
39 pub token_type: String,
40 pub host: Option<String>,
41 pub path: Option<String>,
42}
43
44impl fmt::Debug for GitCredentialMaterial {
45 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
46 f.debug_struct("GitCredentialMaterial")
47 .field("username", &self.username)
48 .field("password", &"[REDACTED]")
49 .field("expires_at", &self.expires_at)
50 .field("token_type", &self.token_type)
51 .field("host", &self.host)
52 .field("path", &self.path)
53 .finish()
54 }
55}