authkestra-core
Core traits and data structures for the authkestra ecosystem.
This crate provides the foundational types and traits used across the authkestra framework, ensuring a consistent API for authentication providers, session stores, and identity management.
Features
Identitystructure for unified user information across different providers.OAuthTokenstructure for standard OAuth2 token responses.OAuthProvidertrait for implementing OAuth2-compatible authentication providers.CredentialsProvidertrait for password-based or custom credential authentication.AuthenticationStrategytrait for implementing modular authentication strategies.UserMappertrait for mapping provider identities to local application users.pkcemodule for Proof Key for Code Exchange support.- Standard
AuthErrorenum for consistent error handling.
Usage
Add this to your Cargo.toml:
[]
= "0.1.2"
Core Traits
OAuthProvider
The OAuthProvider trait defines the interface for OAuth2 providers. It includes methods for generating authorization URLs and exchanging codes for identities.
CredentialsProvider
The CredentialsProvider trait is used for non-OAuth authentication methods, such as email/password.
Authentication Strategies
The strategy module provides the AuthenticationStrategy trait, which allows for implementing modular authentication methods (e.g., Token, Session, Basic).
While authkestra-flow handles the high-level login flows (OAuth2, OIDC), AuthkestraGuard (from authkestra-guard) is used to protect your API routes by validating incoming requests against one or more strategies.
Relationship with Authkestra
AuthkestraGuard (from authkestra-guard) and Authkestra (from authkestra-flow) are designed to be used together but remain decoupled:
Authkestra: Manages the Login Flow (e.g., redirecting to GitHub, handling the callback, creating a session).AuthkestraGuard: Manages Access Control (e.g., checking if a request has a valid session cookie or API key).
By keeping them separate, you can use Authkestra to log users in via OAuth2, and then use AuthkestraGuard to protect your API using both those sessions AND static API keys or JWTs.
UserMapper
The UserMapper trait allows you to bridge the gap between a provider's Identity and your application's local user model.
Part of authkestra
This crate is part of the authkestra workspace. authkestra is a modular, framework-agnostic authentication orchestration system for Rust.