1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! JWT Infrastructure - Shared JWT validation and signing for TurboMCP
//!
//! This module provides a unified JWT handling layer used by both:
//! - Bearer token validation (MCP servers)
//! - DPoP proof generation/validation (RFC 9449)
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────┐
//! │ JWT Infrastructure (Foundation) │
//! │ - JWKS fetching & caching │
//! │ - Algorithm support │
//! │ - Validation (aud/iss/exp/nbf) │
//! │ - Signing support │
//! └─────────────────────────────────────┘
//! ▲ ▲
//! │ │
//! ┌──────┴──────┐ ┌─────┴──────┐
//! │ Bearer │ │ DPoP │
//! │ Validation │ │ Proofs │
//! └─────────────┘ └────────────┘
//! ```
//!
//! # Design Principles
//!
//! - **Industry Standard**: Uses `jsonwebtoken` crate (9.3M downloads)
//! - **Security First**: JWKS caching with TTL, clock skew tolerance
//! - **MCP Compliant**: Audience validation, issuer validation
//! - **Production Ready**: Comprehensive error handling, observability
//!
//! # Modules
//!
//! - `validator` - JWT validation with JWKS support
//! - `signer` - JWT signing (for DPoP, service tokens)
//! - `jwks` - JWKS fetching and caching
//! - `claims` - Common JWT claims handling
// Re-export commonly used types
pub use ;
pub use ;
use ;
use ;
use HashMap;
/// Standard JWT claims per RFC 7519
///
/// This struct represents the registered claims defined in RFC 7519 Section 4.1.
/// Additional claims can be stored in the `additional` field.
///
/// The `aud` field accepts both a single string and an array of strings per
/// RFC 7519 §4.1.3, using `serde_with::OneOrMany` to handle both formats.
/// Enterprise IdPs (Google, Azure, Okta) commonly serialize `aud` as an array.