ModKit Auth
Authentication infrastructure for CyberFabric / ModKit.
Overview
The cf-modkit-auth crate provides:
- JWT / JWKS —
KeyProvidertrait,JwksKeyProviderwith background key refresh,ValidationConfig, standard claim constants - Token validation —
TokenValidatortrait,ClaimsError/AuthErrorerror types - Auth configuration —
AuthConfig(issuers, audiences, leeway, JWKS endpoint) - Outbound OAuth2 client credentials —
Tokenhandle with automatic refresh and invalidation,OAuthClientConfig,BearerAuthLayer(tower),HttpClientBuilderExtformodkit-httpintegration - Auth metrics —
AuthMetricstrait withLoggingMetricsandNoOpMetricsimplementations
Outbound OAuth2 quick start
use ;
use HttpClientBuilder;
let token = new
.await?;
let client = new
.with_bearer_auth
.build?;
// Every request gets Authorization: Bearer <token> automatically
let resp = client.get.send.await?;
See examples/ for more patterns (OIDC discovery, token invalidation, shared token, form auth).
License
Licensed under Apache-2.0.