Authkestra

Introduction

Authkestra is a modular, framework-agnostic authentication orchestration system for Rust. designed to be idiomatic and emphasize explicit control flow, strong typing, and composability.

What is Authkestra?

Unlike authentication solutions common in other ecosystems that rely heavily on dynamic middleware and implicit context, Authkestra follows Rust's philosophy of being explicit, composable, and type-safe. Authentication context is never implicitly available—users must explicitly request it via extractors.

example.rs
use authkestra::flow::Authkestra;
use authkestra::axum::AuthSession;

// Initialize Authkestra with typestate pattern
let auth = Authkestra::builder()
    .session_store(Arc::new(MemoryStore::default()))
    .jwt_secret(b"your-secret")
    .build();

// Explicit injection via extractors - no magic!
async fn protected(AuthSession(session): AuthSession) -> impl IntoResponse {
    let user = session.identity;
    format!("Hello, {}!", user.username.unwrap_or_default())
}

Framework Agnostic Core

The core authentication logic in authkestra-flow is pure Rust, completely independent of any web framework. Framework adapters like authkestra-axum provide the integration layer.

Key Features

Modular Design

Strictly separated concerns with composable crates

Explicit Control Flow

No magic middleware or implicit context

Provider Agnostic

Easily implement new OAuth providers via traits

Session & JWT Support

Flexible session stores and stateless token management

Workspace Crates

Authkestra is organized as a Cargo workspace with specialized crates for different responsibilities. You can use the authkestra facade crate with feature flags, or import individual crates directly.

CrateResponsibility
authkestraPrimary facade - re-exports all crates behind features
authkestra-coreFoundational types and traits (Identity, OAuthProvider, SessionStore)
authkestra-flowOrchestrates OAuth2/OIDC flows (Authorization Code, PKCE, Device Flow)
authkestra-sessionSession persistence layer (Memory, Redis, SQL)
authkestra-guardAuthentication guard for multi-strategy orchestration
authkestra-tokenJWT signing, verification, and offline validation
authkestra-oidcOpenID Connect discovery and validation
authkestra-macrosDerive macros to reduce boilerplate (e.g., AuthkestraFromRef)
authkestra-axumAxum integration with extractors and route helpers
authkestra-actixActix-web integration
authkestra-providers-*Concrete provider implementations (GitHub, Google, Discord)

Design Philosophy

Authkestra favors compile-time guarantees over runtime flexibility:

  • Trait-Based Extension: Customization is achieved by implementing traits, not configuring dynamic strategies
  • Explicit Injection: Authentication context is never implicitly available; use extractors like AuthSession
  • Framework Agnostic Core: The flow crate is pure Rust logic, completely independent of any web framework
  • Typestate Pattern: The Authkestra service uses typestates to ensure that only configured features (like sessions or tokens) are accessible at compile-time.

Next Steps

On this page