The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore: files changed crates/openhuman-core/src/security/credentials/ops.rs,crates/openhuman-core/src
Steven Enamakeld173e18ab79c
diff --git a/crates/openhuman-core/src/security/credentials/ops.rs b/crates/openhuman-core/src/security/credentials/ops.rsindex 30835d721d..8f1bbd3dd5 100644--- a/crates/openhuman-core/src/security/credentials/ops.rs+++ b/crates/openhuman-core/src/security/credentials/ops.rs@@ -23,7 +23,10 @@ pub use provider_credentials::{list_provider_credentials, list_provider_credentials_by_prefix, remove_provider_credentials,store_provider_credentials,};-pub use session_query::{auth_get_me, auth_get_session_token_json, auth_get_state, clear_session};+pub use session_query::{+ auth_clear_api_key, auth_get_me, auth_get_session_token_json, auth_get_state,+ auth_store_api_key, clear_session,+};pub use session_store::{decrypt_secret, encrypt_secret, store_session, store_session_with_deferred_validation,};diff --git a/crates/openhuman-core/src/security/credentials/ops/session_query.rs b/crates/openhuman-core/src/security/credentials/ops/session_query.rsindex 9ce21b2aa7..2e0acf59f0 100644--- a/crates/openhuman-core/src/security/credentials/ops/session_query.rs+++ b/crates/openhuman-core/src/security/credentials/ops/session_query.rs@@ -103,6 +103,34 @@ pub async fn auth_get_state(Ok(RpcOutcome::single_log(state, "session state fetched"))}+/// Store the TinyHumans API key as the runtime's backend credential. Library+/// runtimes install it before boot through `api_key::store_api_key_in`; this+/// RPC is the same operation for a running core.+pub async fn auth_store_api_key(+ config: &Config,+ key: &str,+) -> Result<RpcOutcome<super::super::responses::AuthStateResponse>, String> {+ super::super::api_key::store_api_key(config, key).map_err(|e| e.to_string())?;+ crate::cron::scheduler_gate::set_signed_out(false);+ let state = build_session_state(config)?;+ Ok(RpcOutcome::single_log(state, "api key stored"))+}++/// Remove the stored TinyHumans API key. The scheduler gate follows whatever+/// credential remains.+pub async fn auth_clear_api_key(+ config: &Config,+) -> Result<RpcOutcome<serde_json::Value>, String> {+ let removed = super::super::api_key::clear_api_key(config).map_err(|e| e.to_string())?;+ if !super::super::session_support::has_backend_credential(config) {+ crate::cron::scheduler_gate::set_signed_out(true);+ }+ Ok(RpcOutcome::single_log(+ json!({ "removed": removed }),+ "api key cleared",+ ))+}+pub async fn auth_get_session_token_json(config: &Config,) -> Result<RpcOutcome<serde_json::Value>, String> {diff --git a/crates/openhuman-core/src/security/credentials/responses.rs b/crates/openhuman-core/src/security/credentials/responses.rsindex 565eff7079..f1445db033 100644--- a/crates/openhuman-core/src/security/credentials/responses.rs+++ b/crates/openhuman-core/src/security/credentials/responses.rs@@ -9,8 +9,18 @@ pub struct AuthStateResponse {pub user_id: Option<String>,pub user: Option<serde_json::Value>,pub profile_id: Option<String>,+ /// Which credential backs `is_authenticated`: `"session"` for an app+ /// session JWT, `"api-key"` for a TinyHumans API key (library runtimes,+ /// no user identity), absent when signed out.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub credential: Option<String>,}+/// `AuthStateResponse::credential` value for an app-session JWT.+pub const CREDENTIAL_SESSION: &str = "session";+/// `AuthStateResponse::credential` value for a TinyHumans API key.+pub const CREDENTIAL_API_KEY: &str = "api-key";+#[derive(Debug, Clone, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct AuthProfileSummary {diff --git a/crates/openhuman-core/src/security/credentials/schemas.rs b/crates/openhuman-core/src/security/credentials/schemas.rsindex eda5aef938..d5123890d1 100644--- a/crates/openhuman-core/src/security/credentials/schemas.rs+++ b/crates/openhuman-core/src/security/credentials/schemas.rs@@ -84,6 +84,11 @@ struct AuthOauthFetchClientKeyParams {integration_id: String,}+#[derive(Debug, Deserialize)]+struct AuthStoreApiKeyParams {+ key: String,+}+#[derive(Debug, Deserialize)]#[serde(rename_all = "camelCase")]struct AuthOauthRevokeParams {@@ -95,6 +100,8 @@ pub fn all_controller_schemas() -> Vec<ControllerSchema> {schemas("auth_store_session"),schemas("auth_clear_session"),schemas("auth_get_state"),+ schemas("auth_store_api_key"),+ schemas("auth_clear_api_key"),schemas("auth_get_session_token"),schemas("auth_get_me"),schemas("auth_consume_login_token"),@@ -124,6 +131,14 @@ pub fn all_registered_controllers() -> Vec<RegisteredController> {schema: schemas("auth_get_state"),handler: handle_auth_get_state,},+ RegisteredController {+ schema: schemas("auth_store_api_key"),+ handler: handle_auth_store_api_key,+ },+ RegisteredController {+ schema: schemas("auth_clear_api_key"),+ handler: handle_auth_clear_api_key,+ },RegisteredController {schema: schemas("auth_get_session_token"),handler: handle_auth_get_session_token,@@ -206,6 +221,21 @@ pub fn schemas(function: &str) -> ControllerSchema {inputs: vec![],outputs: vec![json_output("state", "Current auth state response.")],},+ "auth_store_api_key" => ControllerSchema {+ namespace: "auth",+ function: "store_api_key",+ description: "Store a TinyHumans API key as the backend credential (no user \+ session; managed inference sends it as a bearer, REST as x-api-key).",+ inputs: vec![required_string("key", "TinyHumans API key.")],+ outputs: vec![json_output("state", "Auth state after storing the key.")],+ },+ "auth_clear_api_key" => ControllerSchema {+ namespace: "auth",+ function: "clear_api_key",+ description: "Remove the stored TinyHumans API key.",+ inputs: vec![],+ outputs: vec![json_output("result", "Whether a key was removed.")],+ },"auth_get_session_token" => ControllerSchema {namespace: "auth",function: "get_session_token",@@ -365,6 +395,21 @@ fn handle_auth_get_state(_params: Map<String, Value>) -> ControllerFuture {})}+fn handle_auth_store_api_key(params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move {+ let config = config_rpc::load_config_with_timeout().await?;+ let payload = deserialize_params::<AuthStoreApiKeyParams>(params)?;+ to_json(crate::security::credentials::rpc::auth_store_api_key(&config, &payload.key).await?)+ })+}++fn handle_auth_clear_api_key(_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_clear_api_key(&config).await?)+ })+}+fn handle_auth_get_session_token(_params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {let config = config_rpc::load_config_with_timeout().await?;diff --git a/crates/openhuman-core/src/security/credentials/session_support.rs b/crates/openhuman-core/src/security/credentials/session_support.rsindex 605b089c1c..4acea5b6de 100644--- a/crates/openhuman-core/src/security/credentials/session_support.rs+++ b/crates/openhuman-core/src/security/credentials/session_support.rs@@ -134,7 +134,14 @@ fn session_user_value(pub fn build_session_state(config: &Config) -> Result<AuthStateResponse, String> {let profile = load_app_session_profile(config)?;- Ok(session_state_from_profile(profile.as_ref()))+ let mut state = session_state_from_profile(profile.as_ref());+ // An API key authenticates the runtime without a user: report it so a+ // host can tell "signed in as nobody" from "signed out".+ if !state.is_authenticated && super::api_key::has_api_key(config) {+ state.is_authenticated = true;+ state.credential = Some(super::responses::CREDENTIAL_API_KEY.to_string());+ }+ Ok(state)}pub fn get_session_token(config: &Config) -> Result<Option<String>, String> {@@ -364,6 +371,7 @@ pub fn session_state_from_profile(profile: Option<&AuthProfile>) -> AuthStateResuser_id: None,user: None,profile_id: None,+ credential: None,};};@@ -378,6 +386,7 @@ pub fn session_state_from_profile(profile: Option<&AuthProfile>) -> AuthStateResuser_id: profile.metadata.get("user_id").cloned(),user: session_user_value(profile),profile_id: Some(profile.id.clone()),+ credential: is_authenticated.then(|| super::responses::CREDENTIAL_SESSION.to_string()),}}