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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//! OAuth 2.0 模块
//!
//! 提供 OAuth 2.0 协议相关的功能实现,包括:
//!
//! - **客户端管理** (`client`): OAuth 客户端的创建、验证和存储
//! - **PKCE** (`pkce`): Proof Key for Code Exchange 支持
//! - **Token** (`token`): OAuth Token 结构和响应类型
//! - **Token 内省** (`introspection`): RFC 7662 Token Introspection
//!
//! ## 功能概述
//!
//! ### 客户端凭证
//!
//! ```rust
//! use authrs::oauth::{OAuthClient, ClientType, GrantType};
//!
//! // 创建机密客户端
//! let (client, secret) = OAuthClient::builder()
//! .name("My Application")
//! .client_type(ClientType::Confidential)
//! .redirect_uri("https://example.com/callback")
//! .grant_type(GrantType::AuthorizationCode)
//! .scope("read")
//! .scope("write")
//! .build()
//! .unwrap();
//!
//! // 保存明文密钥(仅此一次机会)
//! let client_secret = secret.unwrap();
//!
//! // 验证客户端密钥
//! assert!(client.verify_secret(&client_secret));
//! ```
//!
//! ### PKCE (Proof Key for Code Exchange)
//!
//! ```rust
//! use authrs::oauth::{PkceChallenge, PkceMethod};
//!
//! // 生成 PKCE challenge
//! let challenge = PkceChallenge::new(PkceMethod::S256).unwrap();
//!
//! // 获取授权请求参数
//! let (code_challenge, method) = challenge.authorization_params();
//!
//! // 保存 verifier 用于 token 请求
//! let code_verifier = challenge.verifier();
//!
//! // 服务端验证
//! let is_valid = PkceChallenge::verify(code_verifier, code_challenge, PkceMethod::S256);
//! assert!(is_valid);
//! ```
//!
//! ### Token 响应
//!
//! ```rust
//! use authrs::oauth::TokenResponse;
//!
//! let response = TokenResponse::new("access_token_here")
//! .with_expires_in(3600)
//! .with_refresh_token("refresh_token_here")
//! .with_scope("read write");
//! ```
//!
//! ### Token 内省
//!
//! ```rust
//! use authrs::oauth::{IntrospectionRequest, IntrospectionResponse};
//!
//! // 创建内省请求
//! let request = IntrospectionRequest::new("token_to_check");
//!
//! // 创建活跃 token 响应
//! let response = IntrospectionResponse::active()
//! .scope("read write")
//! .client_id("client_123")
//! .subject("user_456")
//! .build();
//! ```
// ============================================================================
// Client 模块导出
// ============================================================================
pub use ;
// ============================================================================
// PKCE 模块导出
// ============================================================================
pub use ;
// ============================================================================
// Token 模块导出
// ============================================================================
pub use ;
// ============================================================================
// Introspection 模块导出
// ============================================================================
pub use ;