Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(auth): remove deprecated desktop and telegram auth callbacks

Steven Enamakele4802bf54b88
diff --git a/crates/openhuman-core/src/core/auth.rs b/crates/openhuman-core/src/core/auth.rs
index 348cee776d..9b8a602982 100644
--- a/crates/openhuman-core/src/core/auth.rs
+++ b/crates/openhuman-core/src/core/auth.rs
@@ -30,9 +30,6 @@
//! Endpoints exempt from auth (checked by [`rpc_auth_middleware`]):
//! - `GET /` — public info page
//! - `GET /health` — liveness probe
-//! - `GET /auth` — desktop login callback fallback; consumes only
-//! one-time login tokens, never raw session JWTs
-//! - `GET /auth/telegram` — external browser callback (carries its own token)
//! - `GET /schema` — read-only schema discovery
//! - `GET /events` — SSE stream; browser `EventSource` cannot set
//! headers, so the handler enforces a bind-token /
@@ -104,8 +101,6 @@ static RPC_TOKEN: OnceLock<String> = OnceLock::new();
const PUBLIC_PATHS: &[&str] = &[
"/",
"/health",
- "/auth",
- "/auth/telegram",
// External browser OAuth redirect for HTTP-remote MCP servers — the
// authorization server posts back here with `?code=…&state=…` and no
// bearer; the one-time `state` (minted in `oauth_begin`) is the guard.
diff --git a/crates/openhuman-core/src/core/auth_tests.rs b/crates/openhuman-core/src/core/auth_tests.rs
index d5dbff0eb9..90841c8445 100644
--- a/crates/openhuman-core/src/core/auth_tests.rs
+++ b/crates/openhuman-core/src/core/auth_tests.rs
@@ -136,7 +136,7 @@ fn extract_query_token_url_decodes_value() {
#[cfg(feature = "http-server")]
#[test]
fn public_paths_include_desktop_auth_callback() {
- assert!(PUBLIC_PATHS.contains(&"/auth"));
+ assert!(!PUBLIC_PATHS.contains(&"/auth"));
}
#[cfg(feature = "http-server")]
diff --git a/crates/openhuman-core/src/core/jsonrpc_tests.rs b/crates/openhuman-core/src/core/jsonrpc_tests.rs
index 32a34f791f..aa128fca29 100644
--- a/crates/openhuman-core/src/core/jsonrpc_tests.rs
+++ b/crates/openhuman-core/src/core/jsonrpc_tests.rs
@@ -1532,107 +1532,6 @@ fn escape_html_is_noop_for_safe_text() {
// --- telegram callback fetch-metadata gate --------------------------------
-#[cfg(feature = "http-server")]
-fn hdr_map(pairs: &[(&str, &str)]) -> axum::http::HeaderMap {
- let mut m = axum::http::HeaderMap::new();
- for (k, v) in pairs {
- m.insert(
- axum::http::HeaderName::from_bytes(k.as_bytes()).unwrap(),
- axum::http::HeaderValue::from_str(v).unwrap(),
- );
- }
- m
-}
-
-#[test]
-#[cfg(feature = "http-server")]
-fn telegram_callback_origin_ok_accepts_no_metadata_headers() {
- // Older browsers and CLI clients (curl) send neither Sec-Fetch-* nor
- // Origin/Referer. The legacy flow has to keep working — reject only
- // when there is evidence of a cross-site embedded context.
- let headers = hdr_map(&[]);
- assert!(super::telegram_callback_origin_ok(&headers).is_ok());
-}
-
-#[test]
-#[cfg(feature = "http-server")]
-fn telegram_callback_origin_ok_accepts_legit_top_nav_from_telegram() {
- let headers = hdr_map(&[
- ("sec-fetch-mode", "navigate"),
- ("sec-fetch-dest", "document"),
- ("sec-fetch-site", "cross-site"),
- ("referer", "https://t.me/some_bot"),
- ]);
- assert!(super::telegram_callback_origin_ok(&headers).is_ok());
-}
-
-#[test]
-#[cfg(feature = "http-server")]
-fn telegram_callback_origin_ok_accepts_same_origin_local_nav() {
- let headers = hdr_map(&[
- ("sec-fetch-mode", "navigate"),
- ("sec-fetch-dest", "document"),
- ("sec-fetch-site", "same-origin"),
- ]);
- assert!(super::telegram_callback_origin_ok(&headers).is_ok());
-}
-
-#[test]
-#[cfg(feature = "http-server")]
-fn telegram_callback_origin_ok_rejects_image_embed() {
- let headers = hdr_map(&[
- ("sec-fetch-mode", "no-cors"),
- ("sec-fetch-dest", "image"),
- ("sec-fetch-site", "cross-site"),
- ]);
- assert!(super::telegram_callback_origin_ok(&headers).is_err());
-}
-
-#[test]
-#[cfg(feature = "http-server")]
-fn telegram_callback_origin_ok_rejects_iframe_embed() {
- let headers = hdr_map(&[
- ("sec-fetch-mode", "navigate"),
- ("sec-fetch-dest", "iframe"),
- ("sec-fetch-site", "cross-site"),
- ]);
- assert!(super::telegram_callback_origin_ok(&headers).is_err());
-}
-
-#[test]
-#[cfg(feature = "http-server")]
-fn telegram_callback_origin_ok_rejects_cross_site_from_non_telegram() {
- let headers = hdr_map(&[
- ("sec-fetch-mode", "navigate"),
- ("sec-fetch-dest", "document"),
- ("sec-fetch-site", "cross-site"),
- ("referer", "https://attacker.example/page"),
- ]);
- assert!(super::telegram_callback_origin_ok(&headers).is_err());
-}
-
-#[test]
-#[cfg(feature = "http-server")]
-fn telegram_callback_origin_ok_rejects_non_telegram_referer_without_fetch_metadata() {
- let headers = hdr_map(&[("referer", "https://attacker.example/post")]);
- assert!(super::telegram_callback_origin_ok(&headers).is_err());
-}
-
-#[test]
-#[cfg(feature = "http-server")]
-fn telegram_callback_origin_ok_rejects_localhost_host_prefix_decoy() {
- // Regression: prefix-matching the referer accepted hostnames like
- // `http://localhost.attacker.example/...`. With exact-host parsing
- // these must be rejected even when no fetch-metadata headers are
- // present.
- let headers = hdr_map(&[("referer", "http://localhost.attacker.example/cb")]);
- assert!(super::telegram_callback_origin_ok(&headers).is_err());
- let headers = hdr_map(&[("referer", "http://127.0.0.1.attacker.example/cb")]);
- assert!(super::telegram_callback_origin_ok(&headers).is_err());
-}
-
-// --- invoke_method parameter-shape errors ---------------------------------
-
#[tokio::test]
async fn invoke_method_rejects_array_params_for_registered_method() {
// Registered controllers expect named-argument style (JSON object).
@@ -1762,65 +1661,6 @@ async fn test_http_health_handler_returns_correct_status() {
);
}
-#[tokio::test]
-#[cfg(feature = "http-server")]
-async fn desktop_auth_rejects_deprecated_direct_session_token_marker() {
- use axum::body::to_bytes;
- use axum::extract::Query;
- use axum::http::{HeaderMap, StatusCode};
- use axum::response::IntoResponse;
-
- let resp = super::desktop_auth_handler(
- HeaderMap::new(),
- Query(super::DesktopAuthQuery {
- token: Some("eyJ.attacker.session.jwt".to_string()),
- key: Some(" auth ".to_string()),
- }),
- )
- .await
- .into_response();
-
- assert_eq!(resp.status(), StatusCode::BAD_REQUEST);
-
- let body = to_bytes(resp.into_body(), usize::MAX)
- .await
- .expect("response body");
- let body = String::from_utf8(body.to_vec()).expect("html body should be utf8");
- assert!(body.contains("no longer supported"));
- assert!(!body.contains("Sign-in completed"));
-}
-
-#[tokio::test]
-#[cfg(feature = "http-server")]
-async fn desktop_auth_rejects_embedded_fetch_metadata() {
- use axum::body::to_bytes;
- use axum::extract::Query;
- use axum::http::{HeaderMap, HeaderValue, StatusCode};
- use axum::response::IntoResponse;
-
- let mut headers = HeaderMap::new();
- headers.insert("sec-fetch-mode", HeaderValue::from_static("no-cors"));
- headers.insert("sec-fetch-dest", HeaderValue::from_static("image"));
-
- let resp = super::desktop_auth_handler(
- headers,
- Query(super::DesktopAuthQuery {
- token: Some("one-time-login-token".to_string()),
- key: None,
- }),
- )
- .await
- .into_response();
-
- assert_eq!(resp.status(), StatusCode::BAD_REQUEST);
-
- let body = to_bytes(resp.into_body(), usize::MAX)
- .await
- .expect("response body");
- let body = String::from_utf8(body.to_vec()).expect("html body should be utf8");
- assert!(body.contains("must be opened as a browser page"));
-}
-
#[test]
#[cfg(feature = "http-server")]
fn is_wallet_not_configured_error_matches_wallet_constant() {