Skip to content

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

fix(security): remove unused session support module

Steven Enamakel426ab34ebc36
diff --git a/crates/openhuman-core/src/memory/host.rs b/crates/openhuman-core/src/memory/host.rs
index 3020a4ae97..c5f2a0a69a 100644
--- a/crates/openhuman-core/src/memory/host.rs
+++ b/crates/openhuman-core/src/memory/host.rs
@@ -104,8 +104,10 @@ impl MemoryHostConfig for Config {
crate::api::config::effective_backend_api_url(&self.api_url)
}
+ /// The backend bearer: the TinyHumans API key when one is stored, else
+ /// the app-session JWT.
fn session_token(&self) -> Result<Option<String>, String> {
- crate::api::jwt::get_session_token(self)
+ crate::security::credentials::session_support::backend_bearer_secret(self)
}
fn default_model(&self) -> Option<&str> {
diff --git a/crates/openhuman-core/src/modules/memory_host.rs b/crates/openhuman-core/src/modules/memory_host.rs
index d8d909711e..65915e4286 100644
--- a/crates/openhuman-core/src/modules/memory_host.rs
+++ b/crates/openhuman-core/src/modules/memory_host.rs
@@ -279,8 +279,8 @@ impl ComposioCallbacks {
Ok(stored.or(configured))
}
- /// The app-session bearer proxied ("backend") Composio mode authenticates
- /// with.
+ /// The bearer proxied ("backend") Composio mode authenticates with: the
+ /// TinyHumans API key when one is stored, else the app-session JWT.
///
/// Answered from a LIVE config read rather than the install-time snapshot,
/// and that is the whole reason this is a bus member instead of a field on
@@ -289,7 +289,8 @@ impl ComposioCallbacks {
/// every sync fail with an auth error that reads as the user being signed
/// out. Asking per call means the module always gets the one valid now.
///
- /// `Ok(None)` means this host has no session to lend — a signed-out user,
+ /// `Ok(None)` means this host has no credential to lend — a signed-out user
+ /// with no API key,
/// not a broken one. The engine turns that into a named refusal rather than
/// treating it as "nothing to sync", which is the distinction that keeps a
/// signed-out user from looking like a user with no connected sources.
@@ -301,9 +302,13 @@ impl ComposioCallbacks {
/// differently.
async fn session_bearer(&self) -> tinybus::Result<Option<String>> {
let config = self.live_config_or_installed().await;
- Ok(crate::api::jwt::get_session_token(config.as_ref())
+ Ok(
+ crate::security::credentials::session_support::backend_bearer_secret(
+ config.as_ref(),
+ )
.ok()
- .flatten())
+ .flatten(),
+ )
}
/// Whether *some* viable Composio client resolves right now.
diff --git a/crates/openhuman-core/src/security/credentials/session_support.rs b/crates/openhuman-core/src/security/credentials/session_support.rs
index afe56ee5e7..656e725820 100644
--- a/crates/openhuman-core/src/security/credentials/session_support.rs
+++ b/crates/openhuman-core/src/security/credentials/session_support.rs
@@ -383,6 +383,22 @@ pub fn resolve_backend_credential(config: &Config) -> Result<BackendCredential,
}
}
+/// The raw secret a Bearer-only backend caller should send: the stored
+/// TinyHumans API key when there is one, else the stored app-session token
+/// (unclassified, exactly what [`get_session_token`] returns).
+///
+/// For module seams that ask "what bearer can I lend right now?" and treat
+/// `None` as signed out, where [`resolve_backend_credential`]'s error-for-absent
+/// shape does not fit. The backend accepts a key as `Authorization: Bearer`
+/// (it recognises it by prefix), so handing the key over as a bearer is
+/// correct on every route a key may reach.
+pub fn backend_bearer_secret(config: &Config) -> Result<Option<String>, String> {
+ if let Some(key) = super::api_key::get_api_key(config).map_err(|e| e.to_string())? {
+ return Ok(Some(key));
+ }
+ get_session_token(config)
+}
+
/// Whether *some* backend credential is present — an API key or a non-empty
/// app-session token — without classifying expiry. This is the boot-time
/// "signed in?" question the scheduler gate asks: an expired session still