Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to the CreateOS Rust SDK are recorded here.

## Unreleased

### Fixed

- Redact plaintext sandbox access tokens from debug output to prevent
accidental disclosure in logs.

### Added

- Sandbox access token creation, inspection, rotation, and disabling methods.
Expand Down
1 change: 1 addition & 0 deletions src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ mod access_token_tests {

let created = owner.create_access_token().await.unwrap();
assert_eq!(created.token, "skp_sb_first");
assert!(!format!("{created:?}").contains(&created.token));
assert!(created.enabled && created.rotated_at.is_none());
assert_eq!(
owner
Expand Down
14 changes: 13 additions & 1 deletion src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ Sandbox {
});

/// Plaintext delegated token returned only when created or rotated.
#[derive(Clone, Debug, Deserialize)]
#[derive(Clone, Deserialize)]
pub struct SandboxAccessTokenCreateResponse {
/// Delegated credential. Store it securely; it cannot be read again.
pub token: String,
Expand All @@ -368,6 +368,18 @@ pub struct SandboxAccessTokenCreateResponse {
pub rotated_at: Option<DateTime<Utc>>,
}

impl fmt::Debug for SandboxAccessTokenCreateResponse {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter
.debug_struct("SandboxAccessTokenCreateResponse")
.field("token", &"[REDACTED]")
.field("enabled", &self.enabled)
.field("created_at", &self.created_at)
.field("rotated_at", &self.rotated_at)
.finish()
}
}

/// Delegated token state without plaintext credential material.
#[derive(Clone, Debug, Deserialize)]
pub struct SandboxAccessTokenMetadata {
Expand Down
Loading