Skip to content

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

fix(credentials): remove unused login token and session query modules

Steven Enamakel01ebec886f72
diff --git a/crates/openhuman-core/src/security/credentials/ops.rs b/crates/openhuman-core/src/security/credentials/ops.rs
index 978675641f..6f34512292 100644
--- a/crates/openhuman-core/src/security/credentials/ops.rs
+++ b/crates/openhuman-core/src/security/credentials/ops.rs
@@ -26,7 +26,7 @@ pub use gated_services::{
start_credential_gated_services, start_login_gated_services, stop_credential_gated_services,
stop_login_gated_services,
};
-pub use login_tokens::{auth_create_channel_link_token, consume_login_token};
+pub use login_tokens::auth_create_channel_link_token;
pub use oauth::{
oauth_connect, oauth_fetch_client_key, oauth_fetch_integration_tokens, oauth_list_integrations,
oauth_revoke_integration,
@@ -36,7 +36,7 @@ pub use provider_credentials::{
store_provider_credentials,
};
pub use secrets::{decrypt_secret, encrypt_secret};
-pub use session_query::{auth_get_me, auth_get_session_token_json, auth_get_state};
+pub use session_query::{auth_get_session_token_json, auth_get_state};
#[cfg(test)]
pub(crate) use secrets::secret_store_for_config;
diff --git a/crates/openhuman-core/src/security/credentials/ops/login_tokens.rs b/crates/openhuman-core/src/security/credentials/ops/login_tokens.rs
index 70f3c004ea..a785ccf25e 100644
--- a/crates/openhuman-core/src/security/credentials/ops/login_tokens.rs
+++ b/crates/openhuman-core/src/security/credentials/ops/login_tokens.rs
@@ -1,4 +1,4 @@
-//! Backend login-token exchange and channel-link token issuance.
+//! Channel-link token issuance (an authed backend call; bearer only).
use crate::api::config::effective_backend_api_url;
use crate::api::jwt::get_session_token;
@@ -6,35 +6,6 @@ use crate::api::rest::BackendOAuthClient;
use crate::config::Config;
use crate::rpc::RpcOutcome;
-pub async fn consume_login_token(
- config: &Config,
- login_token: &str,
-) -> Result<RpcOutcome<serde_json::Value>, String> {
- let token = login_token.trim();
- if token.is_empty() {
- return Err("loginToken is required".to_string());
- }
-
- let api_url = effective_backend_api_url(&config.api_url);
- let client = BackendOAuthClient::new(&api_url).map_err(|e| e.to_string())?;
- let jwt_token = client
- .consume_login_token(token)
- .await
- // See `auth_get_me` above for why we walk the full anyhow chain.
- .map_err(|e| format!("{e:#}"))?;
-
- Ok(RpcOutcome::new(
- serde_json::json!({ "jwtToken": jwt_token }),
- vec![
- format!(
- "login token consumed via POST /auth/login-token/consume on {}",
- api_url.trim_end_matches('/')
- ),
- "session JWT received".to_string(),
- ],
- ))
-}
-
pub async fn auth_create_channel_link_token(
config: &Config,
channel: &str,
@@ -54,8 +25,8 @@ pub async fn auth_create_channel_link_token(
let payload = client
.create_channel_link_token(&channel, &token)
.await
- // See `auth_get_me` above: same authed backend route, same need to keep
- // the typed 401 classifiable while non-401s keep their full anyhow chain.
+ // Keeps the typed 401 classifiable as session expiry while non-401s
+ // keep their full anyhow chain.
.map_err(crate::api::flatten_authed_error)?;
Ok(RpcOutcome::single_log(
diff --git a/crates/openhuman-core/src/security/credentials/ops/session_query.rs b/crates/openhuman-core/src/security/credentials/ops/session_query.rs
index 2510b8502b..9eb73977df 100644
--- a/crates/openhuman-core/src/security/credentials/ops/session_query.rs
+++ b/crates/openhuman-core/src/security/credentials/ops/session_query.rs
@@ -2,9 +2,7 @@
use serde_json::json;
-use crate::api::config::effective_backend_api_url;
use crate::api::jwt::get_session_token;
-use crate::api::rest::BackendOAuthClient;
use crate::config::Config;
use crate::rpc::RpcOutcome;
use crate::security::credentials::session_support::build_session_state;
@@ -25,37 +23,3 @@ pub async fn auth_get_session_token_json(
"session token fetched",
))
}
-
-pub async fn auth_get_me(config: &Config) -> Result<RpcOutcome<serde_json::Value>, String> {
- let api_url = effective_backend_api_url(&config.api_url);
- let token = get_session_token(config)?.ok_or_else(|| "session JWT required".to_string())?;
- let client = BackendOAuthClient::new(&api_url).map_err(|e| e.to_string())?;
- let user = client
- .fetch_current_user(&token)
- .await
- // `flatten_authed_error` maps the typed `BackendApiError::Unauthorized`
- // onto the `SESSION_EXPIRED:` sentinel and falls through to `{e:#}` for
- // everything else, so both properties this call site needs are kept:
- //
- // * Non-401s still render the full anyhow context chain, so the
- // underlying reqwest transport error (timeout / connection reset /
- // TLS / DNS) reaches `observability::is_transient_message_failure`.
- // Bare `e.to_string()` renders only the top context layer
- // ("GET /auth/me") and collapsed every transient transport failure
- // into Sentry TAURI-RUST-10.
- // * A 401 is recognised by `jsonrpc::is_session_expired_error`, which
- // skips the Sentry report AND publishes `DomainEvent::SessionExpired`
- // so `SessionExpiredSubscriber` clears the dead JWT.
- //
- // Until #5232 routed `fetch_current_user` through `authed_json`, a 401
- // here surfaced as `"GET /auth/me failed (401 Unauthorized): …"`, which
- // `is_session_expired_error` matched on its HTTP-verb prefix. The typed
- // error renders as `"backend rejected session token on GET /auth/me"`,
- // which matches neither classifier — so on 0.63.9 every lapsed session
- // reported to Sentry as a code defect (TAURI-RUST-RYD) and, because the
- // stale token was never cleared, re-fired the same 401 on the next
- // revalidation: the forced sign-out loop in #5307.
- .map_err(crate::api::flatten_authed_error)?;
-
- Ok(RpcOutcome::single_log(user, "current user fetched"))
-}
diff --git a/crates/openhuman-core/src/security/credentials/schemas.rs b/crates/openhuman-core/src/security/credentials/schemas.rs
index 64d830a5cc..5553d63749 100644
--- a/crates/openhuman-core/src/security/credentials/schemas.rs
+++ b/crates/openhuman-core/src/security/credentials/schemas.rs
@@ -7,23 +7,6 @@ use crate::core::all::{ControllerFuture, RegisteredController};
use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
use crate::rpc::RpcOutcome;
-#[derive(Debug, Deserialize)]
-struct AuthStoreSessionParams {
- token: String,
- #[serde(default, alias = "userId")]
- user_id: Option<String>,
- #[serde(default)]
- user: Option<serde_json::Value>,
- #[serde(default, alias = "allowPendingBackendValidation")]
- allow_pending_backend_validation: Option<bool>,
-}
-
-#[derive(Debug, Deserialize)]
-#[serde(rename_all = "camelCase")]
-struct AuthConsumeLoginTokenParams {
- login_token: String,
-}
-
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
struct AuthCreateChannelLinkTokenParams {
@@ -101,12 +84,8 @@ pub fn all_controller_schemas() -> Vec<ControllerSchema> {
vec![
schemas("auth_set_credential"),
schemas("auth_clear_credential"),
- schemas("auth_store_session"),
- schemas("auth_clear_session"),
schemas("auth_get_state"),
schemas("auth_get_session_token"),
- schemas("auth_get_me"),
- schemas("auth_consume_login_token"),
schemas("auth_create_channel_link_token"),
schemas("auth_store_provider_credentials"),
schemas("auth_remove_provider_credentials"),
@@ -129,14 +108,6 @@ pub fn all_registered_controllers() -> Vec<RegisteredController> {
schema: schemas("auth_clear_credential"),
handler: handle_auth_clear_credential,
},
- RegisteredController {
- schema: schemas("auth_store_session"),
- handler: handle_auth_store_session,
- },
- RegisteredController {
- schema: schemas("auth_clear_session"),
- handler: handle_auth_clear_session,
- },
RegisteredController {
schema: schemas("auth_get_state"),
handler: handle_auth_get_state,
@@ -145,14 +116,6 @@ pub fn all_registered_controllers() -> Vec<RegisteredController> {
schema: schemas("auth_get_session_token"),
handler: handle_auth_get_session_token,
},
- RegisteredController {
- schema: schemas("auth_get_me"),
- handler: handle_auth_get_me,
- },
- RegisteredController {
- schema: schemas("auth_consume_login_token"),
- handler: handle_auth_consume_login_token,
- },
RegisteredController {
schema: schemas("auth_create_channel_link_token"),
handler: handle_auth_create_channel_link_token,
@@ -233,27 +196,6 @@ pub fn schemas(function: &str) -> ControllerSchema {
)],
outputs: vec![json_output("result", "Which credentials were removed.")],
},
- "auth_store_session" => ControllerSchema {
- namespace: "auth",
- function: "store_session",
- description: "Historical alias for set_credential with a session or local token.",
- inputs: vec![
- required_string("token", "Session JWT token."),
- optional_json("user_id", "Optional user id hint."),
- optional_json("user", "Optional user payload."),
- ],
- outputs: vec![json_output(
- "state",
- "Auth state after installing the credential.",
- )],
- },
- "auth_clear_session" => ControllerSchema {
- namespace: "auth",
- function: "clear_session",
- description: "Historical alias for clear_credential with kind \"session\".",
- inputs: vec![],
- outputs: vec![json_output("result", "Session clear result payload.")],
- },
"auth_get_state" => ControllerSchema {
namespace: "auth",
function: "get_state",
@@ -268,20 +210,6 @@ pub fn schemas(function: &str) -> ControllerSchema {
inputs: vec![],
outputs: vec![json_output("token", "Session token payload.")],
},
- "auth_get_me" => ControllerSchema {
- namespace: "auth",
- function: "get_me",
- description: "Fetch the current authenticated backend user profile.",
- inputs: vec![],
- outputs: vec![json_output("user", "Current authenticated user payload.")],
- },
- "auth_consume_login_token" => ControllerSchema {
- namespace: "auth",
- function: "consume_login_token",
- description: "Consume login handoff token and return session JWT.",
- inputs: vec![required_string("loginToken", "One-time login token.")],
- outputs: vec![json_output("result", "Consumed login token result.")],
- },
"auth_create_channel_link_token" => ControllerSchema {
namespace: "auth",
function: "create_channel_link_token",
@@ -409,34 +337,6 @@ fn handle_auth_clear_credential(params: Map<String, Value>) -> ControllerFuture
})
}
-fn handle_auth_store_session(params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
- let payload = deserialize_params::<AuthStoreSessionParams>(params)?;
- if payload.allow_pending_backend_validation.is_some() {
- log::debug!(
- "[auth] store_session: allowPendingBackendValidation is ignored; the core no longer validates sessions"
- );
- }
- to_json(
- crate::security::credentials::rpc::store_session(
- &config,
- &payload.token,
- payload.user_id,
- payload.user,
- )
- .await?,
- )
- })
-}
-
-fn handle_auth_clear_session(_params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
- to_json(crate::security::credentials::rpc::clear_session(&config).await?)
- })
-}
-
fn handle_auth_get_state(_params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let config = config_rpc::load_config_with_timeout().await?;
@@ -451,27 +351,6 @@ fn handle_auth_get_session_token(_params: Map<String, Value>) -> ControllerFutur
})
}
-fn handle_auth_get_me(_params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
- to_json(crate::security::credentials::rpc::auth_get_me(&config).await?)
- })
-}
-
-fn handle_auth_consume_login_token(params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
- let payload = deserialize_params::<AuthConsumeLoginTokenParams>(params)?;
- to_json(
- crate::security::credentials::rpc::consume_login_token(
- &config,
- payload.login_token.trim(),
- )
- .await?,
- )
- })
-}
-
fn handle_auth_create_channel_link_token(params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let config = config_rpc::load_config_with_timeout().await?;