litellm/litellm-rust/crates/gateway-ui
yuneng-jiang a6f6c64b6e
feat(ui): adopt the new LiteLLM logo and monogram (#43913)
* feat(ui): adopt the new LiteLLM logo and monogram

Swap the bundled admin UI logos for the new brand assets: the primary
logo in blue for light mode and white for dark mode, and the monogram for
the collapsed sidebar, favicons, and the built-in guardrail cards.

/get_image gains a variant=monogram query parameter so the collapsed
sidebar can request the monogram while admin-configured UI_LOGO_PATH /
UI_LOGO_PATH_DARK logos still take precedence. The bundled light logo
moves from JPEG to a transparent PNG.

* test(ui): query collapsed sidebar logos by role to stay within the lint budget

* fix: point remaining logo consumers at the new bundled assets

The Rust gateway UI served /get_image from the removed litellm_logo.jpg,
the non-root get_image tests pinned logo.jpg, and a cookbook script read
litellm/proxy/logo.jpg. Point them at the monogram and logo.png.

* fix(mcp): serve the BYOK OAuth page logo from /get_image

The page pointed at /ui/assets/logos/litellm_logo.jpg, which the rebrand
removes from the dashboard sources, so the next UI build would drop it.
/get_image?variant=monogram is always served by the proxy and follows any
admin-configured logo.

* fix(ui): invert the LiteLLM monogram on dark guardrail cards

The blue monogram has a transparent train cut-out, so on a dark card it
read as a muddy blue block. Inverting it yields the brand's white mark,
which the logo guidelines prescribe for dark backgrounds.

* fix(gateway-ui): serve theme and variant aware logos from the dashboard export

The Rust gateway served one monogram for every /get_image request, and the
committed export lacked it, so /get_image returned 404 until the next UI
release build. Pick the full or monogram logo in light or dark from the
query, ship those assets in the dashboard's public dir and the committed
export, and drop two comments that restated asserted paths.
2026-09-30 14:51:06 -07:00
..
src feat(ui): adopt the new LiteLLM logo and monogram (#43913) 2026-09-30 14:51:06 -07:00
tests feat(ui): adopt the new LiteLLM logo and monogram (#43913) 2026-09-30 14:51:06 -07:00
Cargo.toml feat(ui): adopt the new LiteLLM logo and monogram (#43913) 2026-09-30 14:51:06 -07:00
README.md feat(rust): add gateway UI login and sessions (#43469) 2026-09-27 19:37:41 -07:00

Gateway UI

Provides UI login and sessions independently of the frontend build layout

router(backend, store, secure_cookies) serves login, session, and discovery endpoints without reading files. static_assets(directory) mounts any static export under /ui/, preserving its file layout and directory redirects. The export must use relative asset URLs or URLs rooted at /ui/; missing paths return 404. No framework or asset directory name is assumed

Compose them with Axum:

let ui = litellm_gateway_ui::router(backend, store, true)
    .merge(litellm_gateway_ui::static_assets(directory));

dashboard_assets(directory) wraps the generic mount with the existing dashboard's _next aliases and branding routes. The gateway executable explicitly selects that adapter to preserve existing dashboard URLs. A different frontend can use static_assets or supply its own Axum router

gateway owns environment configuration and server startup. gateway-auth implements the local administrator backend and the UiSession extractor. The login response and discovery schema still follow the current dashboard's HTTP contract

Run from litellm-rust with an existing dashboard export and a gateway config:

export LITELLM_CONFIG=/path/to/config.yaml
export LITELLM_UI_PATH=/path/to/litellm/proxy/_experimental/out
export UI_USERNAME=admin
read -rs UI_PASSWORD
export UI_PASSWORD
cargo run -p litellm-gateway

Open /ui/login/ to sign in. HTTPS cookies are enabled by default. For local HTTP development only, set LITELLM_UI_SECURE_COOKIES=false. Omitting LITELLM_UI_PATH leaves UI routes disabled. UI_PASSWORD is required when the UI is enabled, and never falls back to the inference master key

POST /v2/login accepts JSON credentials and returns the dashboard's token and redirect URL. axum-login handles authenticated sessions through tower-sessions. Login rotates the session, sets an absolute 24-hour expiry, and issues an HttpOnly litellm_session cookie. The JavaScript-readable token cookie contains display claims and a CSRF token in its key field. It contains neither the master key nor the session ID

GET /session/info and POST /session/logout require both the session cookie and Authorization: Bearer <key> from the dashboard token. The session's stored user determines authorization; client-supplied JWT claims do not. Logout deletes the server-side session and clears both cookies. JSON-only login prevents cross-origin form submissions, and login attempts use a shared token bucket with a burst of ten and a refill rate of ten per minute per gateway process

The gateway uses a process-local Moka session store with expiry and a capacity of 10,000 sessions. Restarts invalidate sessions, and capacity eviction can sign users out early. Multi-process deployments need a shared SessionStore supplied to the router

The current scope is local administrator login, sessions, discovery, and static assets. SSO, database-backed users, cross-origin workers, custom URL prefixes, and management APIs are not implemented. Dashboard screens that call management APIs still require those routes. UI request and response bodies are excluded from the inference gateway's debug body logger

Run the regression suite from litellm-rust without a browser, dashboard build, running proxy, or provider credentials:

cargo test -p litellm-gateway-ui -p litellm-gateway-auth -p litellm-gateway --locked -- --test-threads=1

gateway-ui/tests/routes.rs tests discovery, login, cookies, validation, rate limits, CSRF, expiry, password changes, session rotation, and logout through the real Axum router with an injected session store and no asset files

gateway-ui/tests/assets.rs tests a plain HTML/JavaScript/CSS export without a Next.js directory, including redirects and path traversal rejection. Separate compatibility cases cover the existing dashboard aliases and branding

gateway-auth/tests/ui.rs checks credential matching, empty configuration, user lookup, and password-dependent session hashes. gateway/tests/server.rs checks optional mounting, the production Moka store, credential isolation from inference, local HTTP cookies, and exclusion of login secrets from logs

The command runs serially because the existing gateway logging test can lose tracing events during concurrent tests

These tests cover the gateway's HTTP contract. They do not execute the dashboard's JavaScript or verify visual rendering