Skip to content

Commit af1463f

Browse files
committed
fix: accept challenge name in auth for all routes, not just sudo
Route auth now tries to verify the signature using the original challenge_id (name) first, falling back to the resolved UUID. Clients can sign with 'bounty-challenge' and the server accepts it even though it resolves to a UUID internally.
1 parent c418d66 commit af1463f

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

crates/rpc-server/src/server.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ async fn challenge_route_handler(
356356
.unwrap_or_default()
357357
};
358358

359+
let original_challenge_id = challenge_id;
359360
let challenge_id = resolved_id;
360361

361362
if challenge_routes.is_empty() {
@@ -404,15 +405,30 @@ async fn challenge_route_handler(
404405
}
405406
}
406407

407-
// Verify authentication from headers if present
408+
// Verify authentication from headers if present.
409+
// Try with the original challenge_id (name) first, then the resolved UUID,
410+
// so clients can sign with either the name or the UUID.
408411
let body_bytes = if body.is_null() {
409412
Vec::new()
410413
} else {
411414
serde_json::to_vec(&body).unwrap_or_default()
412415
};
413-
let auth_hotkey =
414-
crate::auth::verify_route_auth(&headers_map, &challenge_id, &method, &path, &body_bytes)
415-
.ok();
416+
let auth_hotkey = crate::auth::verify_route_auth(
417+
&headers_map,
418+
&original_challenge_id,
419+
&method,
420+
&path,
421+
&body_bytes,
422+
)
423+
.ok()
424+
.or_else(|| {
425+
if original_challenge_id != challenge_id {
426+
crate::auth::verify_route_auth(&headers_map, &challenge_id, &method, &path, &body_bytes)
427+
.ok()
428+
} else {
429+
None
430+
}
431+
});
416432

417433
// Enforce auth on routes that require it
418434
if route.requires_auth && auth_hotkey.is_none() {

0 commit comments

Comments
 (0)