Skip to content

Quickstart

This guide will walk you through the fastest way to get a working GitHub OAuth2 login flow using Authkestra. We provide unified integrations for both Axum and Actix-web.

Add the authkestra facade crate to your Cargo.toml. The facade re-exports all sub-crates behind feature flags, allowing you to easily opt-in to the framework and identity providers you need.

[dependencies]
authkestra = { version = "0.2.0", features = ["axum", "github"] }

The core logic of Authkestra is identical regardless of which web framework you choose. First, we will initialize the Identity Provider (GitHub) and then construct the Engine using the Typestate Builder Pattern.

use authkestra::flow::Engine;
use authkestra_providers::github::GithubProvider;
use authkestra_engine::store::memory::MemoryStore;
use std::sync::Arc;
// 1. Initialize the GitHub Provider
let github_provider = GithubProvider::new(
"YOUR_CLIENT_ID".to_string(),
"YOUR_CLIENT_SECRET".to_string(),
"http://localhost:3000/auth/github/callback".to_string()
);
// 2. Setup the Session Store
let session_store = Arc::new(MemoryStore::default());
// 3. Build the Authkestra Engine
let auth_engine = Engine::builder()
.provider(github_provider)
.session_store(session_store)
.build();

Once the engine is built, it’s time to integrate it into your web framework’s routing layer. Authkestra provides specialized adapters (authkestra-axum and authkestra-actix) that automatically map the standard authentication endpoints for you.

use authkestra_axum::AxumExt;
use axum::Router;
use tower_cookies::CookieManagerLayer;
use authkestra::flow::Engine;
use authkestra_engine::AkWebAppEngine;
use authkestra_axum::AxumState;
#[derive(Clone, AxumState)]
struct AppState {
#[authkestra(engine)]
auth: AkWebAppEngine,
}
#[tokio::main]
async fn main() {
let auth_engine = /* setup engine as above */ Engine::builder().build();
let state = AppState { auth: auth_engine.clone() };
let app = Router::new()
// `axum_router()` automatically wires standard login endpoints!
.merge(auth_engine.axum_router())
.layer(CookieManagerLayer::new())
.with_state(state);
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();
}

With just these few lines of code, your application is now fully equipped to handle stateless OAuth logins, validate standard OIDC responses, and issue secure sessions!