From 1b280d0b9be71daf9dffa0f4fa33559eda91946f Mon Sep 17 00:00:00 2001 From: mo khan Date: Mon, 9 Jun 2025 19:39:28 -0600 Subject: Extract a registered client type --- src/http/mod.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/http') diff --git a/src/http/mod.rs b/src/http/mod.rs index 4523d3b..7b1b983 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs @@ -166,8 +166,11 @@ impl Server { fn handle_token(&self, stream: &mut TcpStream, request: &str) { let body = self.extract_body(request); let form_params = self.parse_form_data(&body); + + // Extract Authorization header from request + let auth_header = self.extract_auth_header(request); - match self.oauth_server.handle_token(&form_params) { + match self.oauth_server.handle_token(&form_params, auth_header.as_deref()) { Ok(token_response) => { self.send_json_response(stream, 200, "OK", &token_response); } @@ -200,4 +203,14 @@ impl Server { }) .collect() } + + fn extract_auth_header(&self, request: &str) -> Option { + let lines: Vec<&str> = request.lines().collect(); + for line in lines.iter().skip(1) { // Skip the request line + if line.to_lowercase().starts_with("authorization:") { + return Some(line[14..].trim().to_string()); // Skip "Authorization: " + } + } + None + } } \ No newline at end of file -- cgit v1.2.3