diff options
| author | mo khan <mo@mokhan.ca> | 2025-06-10 08:37:31 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-06-10 08:37:31 -0600 |
| commit | 50867b812214d9454f27d3153cf36d969a7d6c95 (patch) | |
| tree | 85438be0ada067649283a4a6062d7f309df3698f /src/oauth/server.rs | |
| parent | 6280c98938469ac6f8b18dc7341cd47cdfc60ec3 (diff) | |
chore: rustfmt each file
Diffstat (limited to 'src/oauth/server.rs')
| -rw-r--r-- | src/oauth/server.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/oauth/server.rs b/src/oauth/server.rs index 3ee0bb3..243fdba 100644 --- a/src/oauth/server.rs +++ b/src/oauth/server.rs @@ -1,8 +1,8 @@ -use crate::clients::{ClientManager, parse_basic_auth}; +use crate::clients::{parse_basic_auth, ClientManager}; use crate::config::Config; use crate::keys::KeyManager; use crate::oauth::types::{AuthCode, Claims, ErrorResponse, TokenResponse}; -use jsonwebtoken::{Algorithm, Header, encode}; +use jsonwebtoken::{encode, Algorithm, Header}; use std::collections::HashMap; use std::time::{SystemTime, UNIX_EPOCH}; use url::Url; @@ -51,7 +51,8 @@ impl OAuthServer { // Validate client exists let client_manager = self.client_manager.lock().unwrap(); - let _client = client_manager.get_client(client_id) + let _client = client_manager + .get_client(client_id) .ok_or_else(|| self.error_response("invalid_client", "Invalid client_id"))?; // Validate redirect URI is registered for this client @@ -104,7 +105,11 @@ impl OAuthServer { Ok(redirect_url.to_string()) } - pub fn handle_token(&self, params: &HashMap<String, String>, auth_header: Option<&str>) -> Result<String, String> { + pub fn handle_token( + &self, + params: &HashMap<String, String>, + auth_header: Option<&str>, + ) -> Result<String, String> { let grant_type = params .get("grant_type") .ok_or_else(|| self.error_response("invalid_request", "Missing grant_type"))?; @@ -124,8 +129,9 @@ impl OAuthServer { // Clients can authenticate via HTTP Basic Auth or form parameters let (client_id, client_secret) = if let Some(auth_header) = auth_header { // HTTP Basic Authentication (preferred method) - parse_basic_auth(auth_header) - .ok_or_else(|| self.error_response("invalid_client", "Invalid Authorization header"))? + parse_basic_auth(auth_header).ok_or_else(|| { + self.error_response("invalid_client", "Invalid Authorization header") + })? } else { // Form-based authentication (fallback) let client_id = params |
