summaryrefslogtreecommitdiff
path: root/src/oauth/server.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/oauth/server.rs')
-rw-r--r--src/oauth/server.rs18
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