1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! Auth middleware bridge for flowing authenticated identity into agent execution.
//!
//! This module defines the [`RequestContextExtractor`] trait that server operators
//! implement to extract identity from HTTP requests, and the [`RequestContextError`]
//! enum for extraction failures.
//!
//! The extracted [`RequestContext`] (re-exported from `adk-core`) carries user_id,
//! scopes, and metadata into the `InvocationContext`, making scopes available
//! to tools via `ToolContext::user_scopes()`.
//!
//! # Example
//!
//! ```rust,ignore
//! use adk_server::auth_bridge::{RequestContextExtractor, RequestContextError};
//! use adk_core::RequestContext;
//! use async_trait::async_trait;
//!
//! struct MyExtractor;
//!
//! #[async_trait]
//! impl RequestContextExtractor for MyExtractor {
//! async fn extract(
//! &self,
//! parts: &axum::http::request::Parts,
//! ) -> Result<RequestContext, RequestContextError> {
//! let auth = parts.headers
//! .get("authorization")
//! .and_then(|v| v.to_str().ok())
//! .ok_or(RequestContextError::MissingAuth)?;
//! // ... validate token, build RequestContext ...
//! # todo!()
//! }
//! }
//! ```
pub use RequestContext;
use async_trait;
/// Extracts authenticated identity from HTTP request headers.
///
/// Implementations typically parse a Bearer token from the `Authorization`
/// header, validate it, and map claims to a [`RequestContext`].
/// Errors that can occur during request context extraction.