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 OAuth credential types

Steven Enamakel072c9449e4cf
diff --git a/crates/openhuman-core/src/security/credentials/mod.rs b/crates/openhuman-core/src/security/credentials/mod.rs
index f82b924e38..ac01fd1104 100644
--- a/crates/openhuman-core/src/security/credentials/mod.rs
+++ b/crates/openhuman-core/src/security/credentials/mod.rs
@@ -15,10 +15,7 @@ pub mod sentry_scope;
pub mod session_support;
pub mod tools;
-pub use crate::api::rest::{
- decrypt_handoff_blob, user_id_from_profile_payload, BackendOAuthClient, ConnectResponse,
- IntegrationSummary, IntegrationTokensHandoff,
-};
+pub use crate::api::rest::{decrypt_handoff_blob, user_id_from_profile_payload, BackendOAuthClient};
pub use core::*;
pub use credential_ref::{CredentialRef, CredentialRefError, CredentialRefScheme, ResolvedSecret};
pub use http_creds::{
diff --git a/crates/openhuman-core/src/security/credentials/ops.rs b/crates/openhuman-core/src/security/credentials/ops.rs
index 6f34512292..12ea55f33c 100644
--- a/crates/openhuman-core/src/security/credentials/ops.rs
+++ b/crates/openhuman-core/src/security/credentials/ops.rs
@@ -4,7 +4,6 @@ mod boot_env;
mod composio;
mod credential;
mod gated_services;
-mod login_tokens;
mod oauth;
mod provider_credentials;
mod secrets;
@@ -26,11 +25,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;
-pub use oauth::{
- oauth_connect, oauth_fetch_client_key, oauth_fetch_integration_tokens, oauth_list_integrations,
- oauth_revoke_integration,
-};
+pub use oauth::oauth_fetch_client_key;
pub use provider_credentials::{
list_provider_credentials, list_provider_credentials_by_prefix, remove_provider_credentials,
store_provider_credentials,
diff --git a/crates/openhuman-core/src/security/credentials/ops/oauth.rs b/crates/openhuman-core/src/security/credentials/ops/oauth.rs
index 36d4a95690..2c5d3c2a0f 100644
--- a/crates/openhuman-core/src/security/credentials/ops/oauth.rs
+++ b/crates/openhuman-core/src/security/credentials/ops/oauth.rs
@@ -1,4 +1,12 @@
-//! Backend-brokered OAuth connect flow and integration token/key retrieval.
+//! The one backend-brokered OAuth call the core still serves.
+//!
+//! `auth.oauth_connect`, `auth.oauth_list_integrations`,
+//! `auth.oauth_fetch_integration_tokens` and `auth.oauth_revoke_integration`
+//! moved to `openhuman-tinyhumans` (`hosted::oauth`, on the TinyHumans SDK).
+//! `auth.oauth_fetch_client_key` stays here because its route
+//! (`POST /auth/integrations/{id}/client-key`) has no SDK method and is absent
+//! from the SDK's public-route registry; it moves once the route is added to
+//! the SDK upstream.
use serde_json::json;
@@ -8,62 +16,6 @@ use crate::api::rest::BackendOAuthClient;
use crate::config::Config;
use crate::rpc::RpcOutcome;
-pub async fn oauth_connect(
- config: &Config,
- provider: &str,
- skill_id: Option<&str>,
- response_type: Option<&str>,
- encryption_mode: Option<&str>,
-) -> 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; complete login and store_session first".to_string()
- })?;
- let client = BackendOAuthClient::new(&api_url).map_err(|e| e.to_string())?;
- let r = client
- .connect(provider, &token, skill_id, response_type, encryption_mode)
- .await
- .map_err(|e| e.to_string())?;
- Ok(RpcOutcome::single_log(
- serde_json::json!({ "oauthUrl": r.oauth_url, "state": r.state }),
- "oauth connect URL ready",
- ))
-}
-
-pub async fn oauth_list_integrations(
- 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 list = client
- .list_integrations(&token)
- .await
- .map_err(|e| e.to_string())?;
- Ok(RpcOutcome::single_log(
- serde_json::to_value(&list).map_err(|e| e.to_string())?,
- "integrations listed",
- ))
-}
-
-pub async fn oauth_fetch_integration_tokens(
- config: &Config,
- integration_id: &str,
- encryption_key: &str,
-) -> 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 tokens = client
- .fetch_integration_tokens_handoff(integration_id, &token, encryption_key)
- .await
- .map_err(|e| e.to_string())?;
- Ok(RpcOutcome::single_log(
- serde_json::to_value(&tokens).map_err(|e| e.to_string())?,
- "integration tokens retrieved",
- ))
-}
-
pub async fn oauth_fetch_client_key(
config: &Config,
integration_id: &str,
@@ -71,10 +23,12 @@ pub async fn oauth_fetch_client_key(
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())?;
+ // `flatten_authed_error` keeps a 401 on the `SESSION_EXPIRED` sentinel (and
+ // a missing transport on `BACKEND_UNAVAILABLE:`) instead of an opaque string.
let client_key = client
.fetch_client_key(integration_id, &token)
.await
- .map_err(|e| e.to_string())?;
+ .map_err(crate::api::flatten_authed_error)?;
log::debug!(
"[credentials] client key retrieved for integration {}",
integration_id
@@ -84,20 +38,3 @@ pub async fn oauth_fetch_client_key(
"client key retrieved (one-time handoff)",
))
}
-
-pub async fn oauth_revoke_integration(
- config: &Config,
- integration_id: &str,
-) -> 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())?;
- client
- .revoke_integration(integration_id, &token)
- .await
- .map_err(|e| e.to_string())?;
- Ok(RpcOutcome::single_log(
- serde_json::json!({ "revoked": true, "integrationId": integration_id }),
- "integration revoked",
- ))
-}
diff --git a/crates/openhuman-core/src/security/credentials/schemas.rs b/crates/openhuman-core/src/security/credentials/schemas.rs
index 9d56c1cae2..5bfe7ed274 100644
--- a/crates/openhuman-core/src/security/credentials/schemas.rs
+++ b/crates/openhuman-core/src/security/credentials/schemas.rs
@@ -7,12 +7,6 @@ use crate::core::all::{ControllerFuture, RegisteredController};
use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
use crate::rpc::RpcOutcome;
-#[derive(Debug, Deserialize)]
-#[serde(rename_all = "camelCase")]
-struct AuthCreateChannelLinkTokenParams {
- channel: String,
-}
-
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
struct AuthStoreProviderCredentialsParams {
@@ -42,25 +36,6 @@ struct AuthListProviderCredentialsParams {
provider: Option<String>,
}
-#[derive(Debug, Deserialize)]
-#[serde(rename_all = "camelCase")]
-struct AuthOauthConnectParams {
- provider: String,
- #[serde(default)]
- skill_id: Option<String>,
- #[serde(default)]
- response_type: Option<String>,
- #[serde(default)]
- encryption_mode: Option<String>,
-}
-
-#[derive(Debug, Deserialize)]
-#[serde(rename_all = "camelCase")]
-struct AuthOauthIntegrationTokensParams {
- integration_id: String,
- key: String,
-}
-
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
struct AuthOauthFetchClientKeyParams {
@@ -74,27 +49,16 @@ struct AuthClearCredentialParams {
kind: Option<String>,
}
-#[derive(Debug, Deserialize)]
-#[serde(rename_all = "camelCase")]
-struct AuthOauthRevokeParams {
- integration_id: String,
-}
-
pub fn all_controller_schemas() -> Vec<ControllerSchema> {
vec![
schemas("auth_set_credential"),
schemas("auth_clear_credential"),
schemas("auth_get_state"),
schemas("auth_get_session_token"),
- schemas("auth_create_channel_link_token"),
schemas("auth_store_provider_credentials"),
schemas("auth_remove_provider_credentials"),
schemas("auth_list_provider_credentials"),
- schemas("auth_oauth_connect"),
- schemas("auth_oauth_list_integrations"),
- schemas("auth_oauth_fetch_integration_tokens"),
schemas("auth_oauth_fetch_client_key"),
- schemas("auth_oauth_revoke_integration"),
]
}
@@ -116,10 +80,6 @@ pub fn all_registered_controllers() -> Vec<RegisteredController> {
schema: schemas("auth_get_session_token"),
handler: handle_auth_get_session_token,
},
- RegisteredController {
- schema: schemas("auth_create_channel_link_token"),
- handler: handle_auth_create_channel_link_token,
- },
RegisteredController {
schema: schemas("auth_store_provider_credentials"),
handler: handle_auth_store_provider_credentials,
@@ -132,26 +92,10 @@ pub fn all_registered_controllers() -> Vec<RegisteredController> {
schema: schemas("auth_list_provider_credentials"),
handler: handle_auth_list_provider_credentials,
},
- RegisteredController {
- schema: schemas("auth_oauth_connect"),
- handler: handle_auth_oauth_connect,
- },
- RegisteredController {
- schema: schemas("auth_oauth_list_integrations"),
- handler: handle_auth_oauth_list_integrations,
- },
- RegisteredController {
- schema: schemas("auth_oauth_fetch_integration_tokens"),
- handler: handle_auth_oauth_fetch_integration_tokens,
- },
RegisteredController {
schema: schemas("auth_oauth_fetch_client_key"),
handler: handle_auth_oauth_fetch_client_key,
},
- RegisteredController {
- schema: schemas("auth_oauth_revoke_integration"),
- handler: handle_auth_oauth_revoke_integration,
- },
]
}
@@ -213,13 +157,6 @@ pub fn schemas(function: &str) -> ControllerSchema {
inputs: vec![],
outputs: vec![json_output("token", "Session token payload.")],
},
- "auth_create_channel_link_token" => ControllerSchema {
- namespace: "auth",
- function: "create_channel_link_token",
- description: "Create a short-lived channel link token for Telegram or Discord.",
- inputs: vec![required_string("channel", "Channel id (telegram|discord).")],
- outputs: vec![json_output("result", "Created channel link token payload.")],
- },
"auth_store_provider_credentials" => ControllerSchema {
namespace: "auth",
function: "store_provider_credentials",
@@ -250,35 +187,6 @@ pub fn schemas(function: &str) -> ControllerSchema {
inputs: vec![optional_string("provider", "Optional provider filter.")],
outputs: vec![json_output("profiles", "Listed provider credentials.")],
},
- "auth_oauth_connect" => ControllerSchema {
- namespace: "auth",
- function: "oauth_connect",
- description: "Create OAuth connect URL for provider.",
- inputs: vec![
- required_string("provider", "Provider id."),
- optional_string("skillId", "Optional skill id."),
- optional_string("responseType", "Optional OAuth response type."),
- optional_string("encryptionMode", "Optional encryption mode ('encrypted')."),
- ],
- outputs: vec![json_output("result", "OAuth connect payload.")],
- },
- "auth_oauth_list_integrations" => ControllerSchema {
- namespace: "auth",
- function: "oauth_list_integrations",
- description: "List OAuth integrations for current session.",
- inputs: vec![],
- outputs: vec![json_output("integrations", "OAuth integration list.")],
- },
- "auth_oauth_fetch_integration_tokens" => ControllerSchema {
- namespace: "auth",
- function: "oauth_fetch_integration_tokens",
- description: "Fetch integration handoff tokens.",
- inputs: vec![
- required_string("integrationId", "Integration id."),
- required_string("key", "Encryption key."),
- ],
- outputs: vec![json_output("tokens", "Integration tokens handoff payload.")],
- },
"auth_oauth_fetch_client_key" => ControllerSchema {
namespace: "auth",
function: "oauth_fetch_client_key",
@@ -289,13 +197,6 @@ pub fn schemas(function: &str) -> ControllerSchema {
)],
outputs: vec![json_output("result", "Client key share payload (base64).")],
},
- "auth_oauth_revoke_integration" => ControllerSchema {
- namespace: "auth",
- function: "oauth_revoke_integration",
- description: "Revoke OAuth integration.",
- inputs: vec![required_string("integrationId", "Integration id.")],
- outputs: vec![json_output("result", "Integration revoke result.")],
- },
_ => ControllerSchema {
namespace: "auth",
function: "unknown",
@@ -354,20 +255,6 @@ fn handle_auth_get_session_token(_params: Map<String, Value>) -> ControllerFutur
})
}
-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?;
- let payload = deserialize_params::<AuthCreateChannelLinkTokenParams>(params)?;
- to_json(
- crate::security::credentials::rpc::auth_create_channel_link_token(
- &config,
- payload.channel.trim(),
- )
- .await?,
- )
- })
-}
-
fn handle_auth_store_provider_credentials(params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let config = config_rpc::load_config_with_timeout().await?;
@@ -422,45 +309,6 @@ fn handle_auth_list_provider_credentials(params: Map<String, Value>) -> Controll
})
}
-fn handle_auth_oauth_connect(params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
- let payload = deserialize_params::<AuthOauthConnectParams>(params)?;
- to_json(
- crate::security::credentials::rpc::oauth_connect(
- &config,
- payload.provider.trim(),
- payload.skill_id.as_deref().map(str::trim),
- payload.response_type.as_deref().map(str::trim),
- payload.encryption_mode.as_deref().map(str::trim),
- )
- .await?,
- )
- })
-}
-
-fn handle_auth_oauth_list_integrations(_params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
- to_json(crate::security::credentials::rpc::oauth_list_integrations(&config).await?)
- })
-}
-
-fn handle_auth_oauth_fetch_integration_tokens(params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
- let payload = deserialize_params::<AuthOauthIntegrationTokensParams>(params)?;
- to_json(
- crate::security::credentials::rpc::oauth_fetch_integration_tokens(
- &config,
- payload.integration_id.trim(),
- payload.key.trim(),
- )
- .await?,
- )
- })
-}
-
fn handle_auth_oauth_fetch_client_key(params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let config = config_rpc::load_config_with_timeout().await?;
@@ -475,20 +323,6 @@ fn handle_auth_oauth_fetch_client_key(params: Map<String, Value>) -> ControllerF
})
}
-fn handle_auth_oauth_revoke_integration(params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
- let payload = deserialize_params::<AuthOauthRevokeParams>(params)?;
- to_json(
- crate::security::credentials::rpc::oauth_revoke_integration(
- &config,
- payload.integration_id.trim(),
- )
- .await?,
- )
- })
-}
-
fn deserialize_params<T: DeserializeOwned>(params: Map<String, Value>) -> Result<T, String> {
serde_json::from_value(Value::Object(params)).map_err(|e| format!("invalid params: {e}"))
}