OpenAgentID documentation
Source referencesRust module referencearsenal-broker

arsenal-broker · middleware

Declared module signatures, types, configuration, and source documentation.

Source: arsenal/crates/arsenal-broker/src/middleware.rs. SHA-256: 4d2db1c3c9b5a9b3b3d6c7bce5a31f954b980e622b1a086bcacdf09d5d1ba94b.

This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.

middleware::auth_middleware

Authentication middleware

Extracts and validates information from mTLS. In production, this extracts the client cert fingerprint from the TLS layer. When behind a TLS-terminating proxy, it reads from X-Client-Cert-Fingerprint header.

Errors

Returns StatusCode::UNAUTHORIZED if a protected request has no verified client identity.

pub async fn auth_middleware(mut request: Request, next: Next) -> Result<Response, StatusCode>;

Source line: 33.

middleware::audit_middleware

Audit logging middleware

Logs all requests for security audit with timing information.

pub async fn audit_middleware(request: Request, next: Next) -> Response;

Source line: 111.

middleware::rate_limit_middleware

Rate limiting middleware

Implements per-agent rate limiting using token bucket algorithm. Rate limits are enforced based on client certificate fingerprint.

Errors

Returns StatusCode errors if the inner handler returns one.

pub async fn rate_limit_middleware(request: Request, next: Next) -> Result<Response, StatusCode>;

Source line: 182.

middleware::http_metrics_middleware

HTTP request metrics middleware.

Records a low-cardinality counter suitable for RED dashboards and SLO accounting: arsenal_http_requests_total{route,method,status}.

pub async fn http_metrics_middleware(request: Request, next: Next) -> Response;

Source line: 232.

middleware::validation_middleware

Request validation middleware

Validates common request properties like content type and size.

Errors

Returns StatusCode::UNSUPPORTED_MEDIA_TYPE if the content type is missing or invalid.

pub async fn validation_middleware(request: Request, next: Next) -> Result<Response, StatusCode>;

Source line: 301.

middleware::security_headers_middleware

Security headers middleware

Adds security-related headers to all responses.

pub async fn security_headers_middleware(request: Request, next: Next) -> Response;

Source line: 337.

middleware::error_handling_middleware

Error handling middleware

Converts panics and errors to proper API responses.

pub async fn error_handling_middleware(request: Request, next: Next) -> Response;

Source line: 384.

On this page