summaryrefslogtreecommitdiff
path: root/src/http
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-06-09 19:39:28 -0600
committermo khan <mo@mokhan.ca>2025-06-09 19:39:28 -0600
commit1b280d0b9be71daf9dffa0f4fa33559eda91946f (patch)
treecc301717deabe901ce82ce469fef6be84c1b2bed /src/http
parent50731865b1a22ab250e988aed2ea2bb8a18f9338 (diff)
Extract a registered client type
Diffstat (limited to 'src/http')
-rw-r--r--src/http/mod.rs15
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