Expand description
Authentication framework for RingKernel.
This module provides a pluggable authentication system with support for multiple methods including API keys, JWT tokens, and OAuth2.
§Feature Flags
auth- Enables JWT token validation (requiresjsonwebtokencrate)
§Example
ⓘ
use ringkernel_core::auth::{AuthProvider, ApiKeyAuth, AuthContext};
// Simple API key authentication
let auth = ApiKeyAuth::new()
.add_key("admin", "secret-key-123", &["admin", "read", "write"])
.add_key("readonly", "readonly-key-456", &["read"]);
let ctx = auth.authenticate(&Credentials::ApiKey("secret-key-123".to_string())).await?;
assert!(ctx.has_permission("write"));
// JWT authentication
let jwt_auth = JwtAuth::new(JwtConfig {
secret: "your-256-bit-secret".to_string(),
issuer: Some("ringkernel".to_string()),
audience: Some("api".to_string()),
..Default::default()
});
let ctx = jwt_auth.authenticate(&Credentials::Bearer(token)).await?;Structs§
- ApiKey
Auth - API key authentication provider.
- Auth
Context - Authentication context for an authenticated request.
- Chained
Auth Provider - Authentication provider that tries multiple providers in order.
- Identity
- Identity of an authenticated principal.
Enums§
- Auth
Error - Error type for authentication operations.
- Credentials
- Credentials provided by a client for authentication.
Traits§
- Auth
Provider - Trait for pluggable authentication providers.
Type Aliases§
- Auth
Result - Result type for authentication operations.