authkestra-flow
High-level authentication flows for authkestra.
This crate orchestrates authentication flows such as OAuth2, Device Flow, Client Credentials, and direct credentials-based auth, providing a high-level API that is independent of web frameworks.
Features
OAuth2Flow: Orchestrates the Authorization Code flow (initiation and finalization).DeviceFlow: Orchestrates the Device Authorization Flow (RFC 8628).ClientCredentialsFlow: Orchestrates the Client Credentials Flow (RFC 6749 Section 4.4).CredentialsFlow: Orchestrates direct credential-based authentication.- Support for
UserMapperto integrate with local user databases.
Usage
Add this to your Cargo.toml:
[]
= "0.1.0"
Example: OAuth2 Flow
use OAuth2Flow;
use GitHubProvider;
// Setup provider and flow
let provider = new;
let flow = new;
// 1. Initiate login: Generate authorization URL and CSRF state
let = flow.initiate_login;
// ... redirect user to auth_url, then receive code and state in callback ...
// 2. Finalize login: Exchange code for identity and tokens
let = flow.finalize_login.await?;
Example: Device Flow
use DeviceFlow;
let flow = new;
// 1. Initiate device authorization
let resp = flow.initiate_device_authorization.await?;
println!;
// 2. Poll for token
let token = flow.poll_for_token.await?;
Example: Client Credentials Flow
use ClientCredentialsFlow;
let flow = new;
// Obtain an access token
let token = flow.get_token.await?;
Example: Credentials Flow
use CredentialsFlow;
// Assuming a provider that implements CredentialsProvider
let flow = new;
let = flow.authenticate.await?;
Part of authkestra
This crate is part of the authkestra workspace.