diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-26 05:45:47 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-26 07:38:58 +0000 |
| commit | 30411a938d072a59d68815c975735d40366ad874 (patch) | |
| tree | f802d1bf9f9959105d2d18af81c528722fa7a675 /src/http | |
| parent | a005132ab806b7177d4eb3e3306914841704ffec (diff) | |
feat: push authorization from state event
Diffstat (limited to 'src/http')
| -rw-r--r-- | src/http/mod.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/http/mod.rs b/src/http/mod.rs index 85b72f4..befa006 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs | |||
| @@ -65,6 +65,7 @@ impl Service<Request<Incoming>> for HttpService { | |||
| 65 | let query = req.uri().query().map(|s| s.to_string()); | 65 | let query = req.uri().query().map(|s| s.to_string()); |
| 66 | let method = req.method().clone(); | 66 | let method = req.method().clone(); |
| 67 | let git_data_path = self.config.git_data_path.clone(); | 67 | let git_data_path = self.config.git_data_path.clone(); |
| 68 | let relay_domain = self.config.domain.clone(); | ||
| 68 | 69 | ||
| 69 | // Handle OPTIONS preflight requests (CORS) | 70 | // Handle OPTIONS preflight requests (CORS) |
| 70 | // GRASP-01 spec line 47: Respond to OPTIONS with 204 No Content | 71 | // GRASP-01 spec line 47: Respond to OPTIONS with 204 No Content |
| @@ -117,9 +118,17 @@ impl Service<Request<Incoming>> for HttpService { | |||
| 117 | git::handlers::handle_upload_pack(repo_path, body_bytes).await | 118 | git::handlers::handle_upload_pack(repo_path, body_bytes).await |
| 118 | } | 119 | } |
| 119 | 120 | ||
| 120 | // POST /git-receive-pack (push) | 121 | // POST /git-receive-pack (push) - with GRASP authorization |
| 121 | (m, "git-receive-pack") if m == Method::POST => { | 122 | (m, "git-receive-pack") if m == Method::POST => { |
| 122 | git::handlers::handle_receive_pack(repo_path, body_bytes.clone()).await | 123 | // Build authorization parameters for GRASP validation |
| 124 | // Use ws:// protocol for relay since we're connecting internally | ||
| 125 | let relay_url = format!("ws://{}", relay_domain); | ||
| 126 | let auth_params = git::handlers::PushAuthParams { | ||
| 127 | relay_url, | ||
| 128 | owner_npub: npub.clone(), | ||
| 129 | identifier: identifier.clone(), | ||
| 130 | }; | ||
| 131 | git::handlers::handle_receive_pack(repo_path, body_bytes.clone(), Some(auth_params)).await | ||
| 123 | } | 132 | } |
| 124 | 133 | ||
| 125 | _ => { | 134 | _ => { |