From ebc91ad0cbc6c72f1a3a7d33c232e95a39536c5a Mon Sep 17 00:00:00 2001 From: Yujong Lee Date: Tue, 8 Sep 2026 15:00:09 -0700 Subject: [PATCH] refactor(rust): extract shared auth foundation from core --- litellm-rust/Cargo.lock | 7 +++++++ litellm-rust/Cargo.toml | 1 + litellm-rust/crates/auth/Cargo.toml | 9 +++++++++ .../crates/{core/src/auth/mod.rs => auth/src/lib.rs} | 0 litellm-rust/crates/core/AGENTS.md | 9 ++++++++- litellm-rust/crates/core/src/lib.rs | 1 - litellm-rust/crates/core/src/providers/mod.rs | 6 ++++++ 7 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 litellm-rust/crates/auth/Cargo.toml rename litellm-rust/crates/{core/src/auth/mod.rs => auth/src/lib.rs} (100%) diff --git a/litellm-rust/Cargo.lock b/litellm-rust/Cargo.lock index badf1dcaf96..f209c6f5e6e 100644 --- a/litellm-rust/Cargo.lock +++ b/litellm-rust/Cargo.lock @@ -1420,6 +1420,13 @@ dependencies = [ "tracing", ] +[[package]] +name = "litellm-auth" +version = "0.1.0" +dependencies = [ + "tokio", +] + [[package]] name = "litellm-auth-aws" version = "0.1.0" diff --git a/litellm-rust/Cargo.toml b/litellm-rust/Cargo.toml index aad642b4993..c610a5e4de4 100644 --- a/litellm-rust/Cargo.toml +++ b/litellm-rust/Cargo.toml @@ -1,6 +1,7 @@ [workspace] members = [ "crates/core", + "crates/auth", "crates/config", "crates/ai-gateway", "crates/python-interop", diff --git a/litellm-rust/crates/auth/Cargo.toml b/litellm-rust/crates/auth/Cargo.toml new file mode 100644 index 00000000000..9f38089ae22 --- /dev/null +++ b/litellm-rust/crates/auth/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "litellm-auth" +version = "0.1.0" +edition.workspace = true +license.workspace = true +repository.workspace = true + +[dev-dependencies] +tokio = { workspace = true, features = ["macros", "rt"] } diff --git a/litellm-rust/crates/core/src/auth/mod.rs b/litellm-rust/crates/auth/src/lib.rs similarity index 100% rename from litellm-rust/crates/core/src/auth/mod.rs rename to litellm-rust/crates/auth/src/lib.rs diff --git a/litellm-rust/crates/core/AGENTS.md b/litellm-rust/crates/core/AGENTS.md index d3a7d80892e..b16689cdabc 100644 --- a/litellm-rust/crates/core/AGENTS.md +++ b/litellm-rust/crates/core/AGENTS.md @@ -101,14 +101,21 @@ errors are language-neutral. ``` core must not depend on PyO3, Axum or gateway integration types +litellm-auth owns shared credential values, capability contracts and future static helpers cloud-auth crates own reusable native credential and signing mechanisms core owns provider precedence, header policy and authorization timing Tower/Axum types stop at the gateway adapter boundary -provider transformation, auth and I/O remain in core +provider transformation, auth policy and I/O remain in core request-scoped host state belongs to a call session service construction dependencies do not leak into service interfaces ``` +`litellm-auth` has only standard-library production dependencies and does not +depend on core or cloud crates. Add it as a dependency only where consumed. +Cloud crates retain their own credential types and errors. `AuthorizationFuture` +lives in `core::providers` because its result uses the core error type. The former +`core::auth` module is removed without compatibility re-exports + ## Not the target Do not introduce a dynamic `TypeId` service map, a shared gateway callback diff --git a/litellm-rust/crates/core/src/lib.rs b/litellm-rust/crates/core/src/lib.rs index 12dde12fc7e..db561666e20 100644 --- a/litellm-rust/crates/core/src/lib.rs +++ b/litellm-rust/crates/core/src/lib.rs @@ -1,5 +1,4 @@ pub mod audio_transcription; -pub mod auth; pub mod chat_completions; pub mod constants; pub mod error; diff --git a/litellm-rust/crates/core/src/providers/mod.rs b/litellm-rust/crates/core/src/providers/mod.rs index c0c2c69831b..b71f3dbb5bb 100644 --- a/litellm-rust/crates/core/src/providers/mod.rs +++ b/litellm-rust/crates/core/src/providers/mod.rs @@ -1,3 +1,6 @@ +use std::future::Future; +use std::pin::Pin; + pub mod anthropic; pub mod azure_ai; #[cfg(feature = "bedrock-auth")] @@ -6,3 +9,6 @@ pub mod mistral; pub mod openai; pub mod reducto; pub mod vertex_ai; + +pub type AuthorizationFuture<'a> = + Pin, crate::Error>> + Send + 'a>>;