upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/git/handlers.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-11-27 15:38:42 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-11-27 15:38:42 +0000
commit6a77173127b5915c4c1b9219924e793795e0d051 (patch)
tree9e7f3d4d023920c5a9cb3a24a871e05abcc1d3b7 /src/git/handlers.rs
parent09025b8435f673779ce109e2fb72ce48a13bf28e (diff)
refactor(auth): simplify state auth with single-query approach
Diffstat (limited to 'src/git/handlers.rs')
-rw-r--r--src/git/handlers.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/git/handlers.rs b/src/git/handlers.rs
index 5b511e3..27bec76 100644
--- a/src/git/handlers.rs
+++ b/src/git/handlers.rs
@@ -9,7 +9,7 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt};
9use tracing::{debug, error, info, warn}; 9use tracing::{debug, error, info, warn};
10 10
11use super::authorization::{ 11use super::authorization::{
12 AuthorizationContext, AuthorizationResult, npub_to_pubkey, parse_pushed_refs, validate_push_refs, 12 AuthorizationContext, AuthorizationResult, parse_pushed_refs, validate_push_refs,
13}; 13};
14use super::protocol::{GitService, PktLine}; 14use super::protocol::{GitService, PktLine};
15use super::subprocess::GitSubprocess; 15use super::subprocess::GitSubprocess;
@@ -258,7 +258,7 @@ pub async fn handle_receive_pack(
258/// 258///
259/// This function: 259/// This function:
260/// 1. Fetches announcement and state events from the relay 260/// 1. Fetches announcement and state events from the relay
261/// 2. Calculates the recursive maintainer set 261/// 2. Collects all authorized publishers from announcements
262/// 3. Gets the latest authorized state 262/// 3. Gets the latest authorized state
263/// 4. Validates that pushed refs match the state 263/// 4. Validates that pushed refs match the state
264async fn authorize_push( 264async fn authorize_push(
@@ -268,9 +268,6 @@ async fn authorize_push(
268 use nostr_sdk::ClientBuilder; 268 use nostr_sdk::ClientBuilder;
269 use std::time::Duration; 269 use std::time::Duration;
270 270
271 // Convert npub to hex pubkey
272 let owner_pubkey = npub_to_pubkey(&params.owner_npub)?;
273
274 debug!( 271 debug!(
275 "Fetching events for identifier {} from relay {}", 272 "Fetching events for identifier {} from relay {}",
276 params.identifier, params.relay_url 273 params.identifier, params.relay_url
@@ -301,8 +298,8 @@ async fn authorize_push(
301 // Create authorization context 298 // Create authorization context
302 let ctx = AuthorizationContext::new(events); 299 let ctx = AuthorizationContext::new(events);
303 300
304 // Get the authorized state 301 // Get the authorized state (no owner_pubkey needed - self-contained check)
305 let auth_result = ctx.get_authorized_state(&owner_pubkey, &params.identifier)?; 302 let auth_result = ctx.get_authorized_state(&params.identifier)?;
306 303
307 if !auth_result.authorized { 304 if !auth_result.authorized {
308 return Ok(auth_result); 305 return Ok(auth_result);