Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| af9359bbdf | |||
| b8c705554f |
@@ -85,31 +85,17 @@ impl crate::proxy::Proxy {
|
||||
description: "Could not start stream".to_string(),
|
||||
});
|
||||
|
||||
// Validate single-use stream token
|
||||
// Validate single-use stream token via the shared helper so this
|
||||
// handler and its unit tests exercise the same code path.
|
||||
let provided_token = req.query::<String>("token").unwrap_or_default();
|
||||
{
|
||||
let mut token_guard = self.stream_token.write().await;
|
||||
match token_guard.take() {
|
||||
Some(expected) if expected == provided_token => {
|
||||
// Token consumed successfully (single-use)
|
||||
if let Err(msg) = super::validate_stream_token(&self, &provided_token).await {
|
||||
error!("Stream token validation failed: {msg}");
|
||||
return Err(AppError {
|
||||
status_code: StatusCode::UNAUTHORIZED,
|
||||
description: msg,
|
||||
});
|
||||
}
|
||||
info!("Stream token validated and consumed");
|
||||
}
|
||||
Some(_) => {
|
||||
error!("Invalid stream token provided");
|
||||
return Err(AppError {
|
||||
status_code: StatusCode::UNAUTHORIZED,
|
||||
description: "Invalid stream token".to_string(),
|
||||
});
|
||||
}
|
||||
None => {
|
||||
error!("Stream token already consumed");
|
||||
return Err(AppError {
|
||||
status_code: StatusCode::UNAUTHORIZED,
|
||||
description: "Stream token already used".to_string(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
info!("WebTransport connection initiated");
|
||||
let (wt_stream_send, wt_stream_recv, wt_datagram_send) = match setup_webtransport(req).await
|
||||
|
||||
Reference in New Issue
Block a user