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
//! OIDC provider support for JWT verification.
//!
//! This module provides support for verifying JWTs from any OIDC-compatible identity provider.
//! It includes functionality for:
//!
//! - Configuring OIDC providers with issuer URL and JWKS URL
//! - Discovering OIDC configuration from well-known endpoints
//! - Verifying ID tokens and access tokens from OIDC providers
//!
//! # Examples
//!
//! ```
//! use jwt_verify::oidc::{OidcProviderConfig, OidcJwtVerifier};
//! use std::time::Duration;
//!
//! // Create a configuration for an OIDC provider
//! let config = OidcProviderConfig::new(
//! "https://accounts.example.com",
//! Some("https://accounts.example.com/.well-known/jwks.json"),
//! &["client1".to_string()],
//! ).unwrap();
//!
//! // Create a verifier with the OIDC provider
//! let verifier = OidcJwtVerifier::new(vec![config]).unwrap();
//!
//! // Verify a token
//! // let token = "..."; // JWT token string
//! // let claims = verifier.verify_id_token(token).await.unwrap();
//! ```
//!
//! ## OIDC Discovery
//!
//! The library supports discovering OIDC provider configuration from well-known endpoints:
//!
//! ```
//! use jwt_verify::oidc::{OidcProviderConfig, discovery::OidcDiscovery};
//! use std::time::Duration;
//!
//! // Create a discovery service
//! let discovery = OidcDiscovery::new(Duration::from_secs(3600));
//!
//! // Discover the configuration for an OIDC provider
//! // let document = discovery.discover("https://accounts.example.com").await.unwrap();
//! // println!("JWKS URI: {}", document.jwks_uri);
//! ```
//!
//! You can also use manual configuration with fallback to discovery:
//!
//! ```
//! use jwt_verify::oidc::{OidcProviderConfig, discovery::OidcDiscovery};
//! use std::time::Duration;
//!
//! // Create a discovery service
//! let discovery = OidcDiscovery::new(Duration::from_secs(3600));
//!
//! // Discover with fallback to manual configuration
//! // let document = discovery.discover_with_fallback(
//! // "https://accounts.example.com",
//! // Some("https://accounts.example.com/.well-known/jwks.json"),
//! // ).await.unwrap();
//! ```
pub use OidcProviderConfig;
pub use DiscoveryDocument;
pub use OidcDiscovery;
pub use OidcJwtVerifier;