adk-auth
Access control and authentication for Rust Agent Development Kit (ADK-Rust).
Overview
adk-auth provides enterprise-grade access control for AI agents:
- Declarative Scope-Based Security - Tools declare required scopes, framework enforces automatically
- Role-Based Access - Define roles with tool/agent permissions (allow/deny, deny precedence)
- Audit Logging - Log all access attempts to JSONL files
- SSO/OAuth - JWT validation with Google, Azure AD, Okta, Auth0 providers
Features
| Feature | Description |
|---|---|
default |
Core RBAC + scope-based security + audit logging |
sso |
JWT/OIDC providers (Google, Azure AD, Okta, Auth0) |
Declarative Scope-Based Security
Tools declare what scopes they need. The framework enforces before execution — no imperative checks in your handlers:
use FunctionTool;
use ;
// Tool declares its required scopes
let transfer = new
.with_scopes;
// ScopeGuard enforces automatically
let guard = new;
let protected = guard.protect;
// Or wrap all tools at once
let protected_tools = guard.protect_all;
With audit logging:
let guard = with_audit;
let protected = guard.protect;
// All scope checks (allowed + denied) are logged
Pluggable resolvers:
| Resolver | Source |
|---|---|
ContextScopeResolver |
Delegates to ToolContext::user_scopes() (JWT claims, session state) |
StaticScopeResolver |
Fixed scopes — useful for testing |
Custom impl ScopeResolver |
Any async source (database, external IdP, etc.) |
Role-Based Access Control
use ;
// Define roles
let admin = new.allow;
let user = new
.allow
.deny;
// Build access control
let ac = builder
.role
.role
.assign
.assign
.build?;
// Protect tools
let middleware = new;
let protected_tools = middleware.protect_all;
SSO Integration
Enable with features = ["sso"]:
use ;
// Create provider
let provider = new;
// Map IdP groups to roles
let mapper = builder
.map_group
.default_role
.user_id_from_email
.build;
// Combined SSO + RBAC
let sso = builder
.validator
.mapper
.access_control
.build?;
// Validate token and check permission
let claims = sso.check_token.await?;
println!;
Providers
| Provider | Usage |
|---|---|
GoogleProvider::new(client_id) |
|
| Azure AD | AzureADProvider::new(tenant_id, client_id) |
| Okta | OktaProvider::new(domain, client_id) |
| Auth0 | Auth0Provider::new(domain, audience) |
| Generic OIDC | OidcProvider::from_discovery(issuer, client_id).await |
Audit Logging
use FileAuditSink;
let audit = new?;
let middleware = with_audit;
Output:
Examples
License
Apache-2.0
Part of ADK-Rust
This crate is part of the ADK-Rust framework for building AI agents in Rust.