diff options
Diffstat (limited to 'src/http')
| -rw-r--r-- | src/http/mod.rs | 15 |
1 files changed, 14 insertions, 1 deletions
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<String> { + 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 |
