Expand description
§TurboMCP DPoP Implementation
RFC 9449 compliant Demonstration of Proof-of-Possession (DPoP) implementation
This crate provides production-grade DPoP support for TurboMCP, implementing the full RFC 9449 specification with enterprise-ready security features:
§Core Features
- ✅ RFC 9449 Compliance - Full specification implementation
- ✅ Cryptographic Security - RSA, ECDSA P-256, and PSS support
- ✅ Token Binding - Prevents stolen token usage
- ✅ Replay Protection - Nonce tracking and timestamp validation
- ✅ Enterprise Ready - HSM integration, audit logging, key rotation
§Quick Start
use turbomcp_dpop::{DpopKeyManager, DpopProofGenerator, DpopAlgorithm};
// Generate key pair for DPoP
let key_manager = DpopKeyManager::new_memory().await?;
let key_pair = key_manager.generate_key_pair(DpopAlgorithm::ES256).await?;
// Create DPoP proof for HTTP request
let proof_gen = DpopProofGenerator::new(key_manager.into());
let proof = proof_gen.generate_proof(
"POST",
"https://api.example.com/oauth/token",
None, // No access token for initial request
).await?;
println!("DPoP Header: {}", proof.to_jwt_string());
§Integration with TurboMCP OAuth
// Example OAuth integration (requires turbomcp crate)
// let config = OAuth2Config {
// // ... existing OAuth configuration
// security_level: SecurityLevel::Enhanced, // 🔒 Enables DPoP
// // ... rest unchanged
// };
§Architecture
┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐
│ Application │ │ TurboMCP OAuth │ │ OAuth Provider │
│ + DPoP Client │ │ + DPoP Support │ │ (GitHub/Google) │
└─────────┬───────────┘ └─────────┬───────────┘ └─────────┬───────────┘
│ │ │
│ 1. Generate DPoP proof │ │
│ │ │
│ 2. OAuth + DPoP header ──┼──────────────────────────▶│
│ │ │
│ │ 3. Validate DPoP proof │
│ │ │
│◄─────────────────────────┼──────────────────────────┤
│ 4. Ephemeral token │ bound to DPoP │
│ (cryptographically bound) │
§Security Properties
§Token Binding
- Access tokens are cryptographically bound to client key pairs
- Stolen tokens are unusable without the corresponding private key
- Each token is tied to a specific client instance
§Replay Attack Prevention
- JWT timestamps prevent token replay beyond time windows
- Nonce tracking ensures each proof is used only once
- HTTP method and URI binding prevents cross-endpoint attacks
§Forward Security
- Key rotation support for long-lived applications
- Ephemeral tokens with short lifespans (1 hour maximum)
- Secure key material destruction on cleanup
Re-exports§
Modules§
- errors
- DPoP error types and conversions
- hsm
- Hardware Security Module (HSM) integration for DPoP key management
- keys
- DPoP key management and cryptographic operations
- proof
- DPoP proof generation and validation
- types
- Core DPoP types and data structures
Constants§
- DEFAULT_
PROOF_ LIFETIME_ SECONDS - Default proof lifetime (60 seconds)
- DPOP_
JWT_ TYPE - DPoP JWT header type as defined in RFC 9449
- MAX_
CLOCK_ SKEW_ SECONDS - Maximum clock skew tolerance (5 minutes)
- MAX_
PROOF_ LIFETIME_ SECONDS - Maximum proof lifetime (5 minutes)
- VERSION
- Current crate version
Type Aliases§
- Result
- DPoP result type