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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//! # Authentication Module
//!
//! Comprehensive authentication system for Azure Service Bus operations supporting
//! multiple authentication methods and providers. This module provides a flexible
//! architecture that can handle various Azure authentication scenarios.
//!
//! ## Supported Authentication Methods
//!
//! ### Azure Active Directory (Azure AD)
//! - **Device Code Flow** - Interactive authentication for CLI applications
//! - **Client Credentials Flow** - Service principal authentication for automated scenarios
//!
//! ### Connection String Authentication
//! - **Shared Access Signature (SAS)** - Token-based authentication using connection strings
//! - **Automatic SAS Token Generation** - Time-limited tokens with configurable expiration
//!
//! ## Architecture Overview
//!
//! The authentication system is built around several key components:
//!
//! - **[`AuthProvider`]** - Core trait defining the authentication interface
//! - **[`AuthStateManager`]** - Centralized state management for authentication
//! - **[`TokenCache`]** - Efficient caching with automatic expiration handling
//! - **[`TokenRefreshService`]** - Background token refresh for long-running operations
//!
//! ## Authentication Providers
//!
//! ### Azure AD Provider
//! ```no_run
//! use quetty_server::auth::{AzureAdProvider, AzureAdAuthConfig};
//!
//! let config = AzureAdAuthConfig {
//! auth_method: "device_code".to_string(),
//! tenant_id: Some("your-tenant-id".to_string()),
//! client_id: Some("your-client-id".to_string()),
//! ..Default::default()
//! };
//!
//! let provider = AzureAdProvider::new(config, http_client)?;
//! let token = provider.authenticate().await?;
//! ```
//!
//! ### Connection String Provider
//! ```no_run
//! use quetty_server::auth::{ConnectionStringProvider, ConnectionStringConfig};
//!
//! let config = ConnectionStringConfig {
//! value: "Endpoint=sb://test.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=...".to_string(),
//! };
//!
//! let provider = ConnectionStringProvider::new(config)?;
//! let token = provider.authenticate().await?;
//! ```
//!
//! ## State Management
//!
//! The [`AuthStateManager`] provides centralized authentication state:
//!
//! ```no_run
//! use quetty_server::auth::AuthStateManager;
//! use std::sync::Arc;
//!
//! let auth_manager = Arc::new(AuthStateManager::new());
//!
//! // Check authentication status
//! if auth_manager.is_authenticated().await {
//! println!("Already authenticated");
//! }
//!
//! // Start automatic token refresh
//! auth_manager.clone().start_refresh_service().await;
//! ```
//!
//! ## Token Caching
//!
//! Automatic token caching with expiration management:
//!
//! ```no_run
//! use quetty_server::auth::TokenCache;
//!
//! let cache = TokenCache::new();
//!
//! // Check if token needs refresh
//! if cache.needs_refresh("user_token").await {
//! // Refresh token...
//! }
//! ```
//!
//! ## Integration with Service Bus
//!
//! The authentication system integrates seamlessly with Service Bus operations:
//!
//! ```no_run
//! use quetty_server::auth::{create_service_bus_auth_provider, get_azure_ad_token_with_auth};
//!
//! // Create provider for Service Bus
//! let provider = create_service_bus_auth_provider(
//! "azure_ad",
//! None,
//! &azure_config,
//! http_client
//! )?;
//!
//! // Get token for operations
//! let token = get_azure_ad_token_with_auth(&provider).await?;
//! ```
pub use ;
pub use ;
pub use ;
pub use ConnectionStringProvider;
pub use TokenRefreshError;
pub use ;
pub use SasTokenGenerator;
pub use ;
pub use TokenCache;
pub use TokenRefreshService;
pub use ;