OpenAgentID documentation
Source referencesRust module referencearsenal-core

arsenal-core · proxy

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

Source: arsenal/crates/arsenal-core/src/proxy.rs. SHA-256: 90e751496306a0bbe03e31e36b1f8df51ed69fa0c85d22a103c6f590e0e15319.

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.

proxy::DestinationBinding

Destination binding restricts which endpoints a credential can reach.

When a secret has a destination binding, proxy requests using that secret are validated against the binding before credential injection. This prevents credential misuse even if an agent's capability token is compromised.

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DestinationBinding {
/// Allowed target domains (e.g., `["api.stripe.com"]`).

/// At least one domain must be specified.

pub allowed_domains: Vec<String>,
/// Optional allowed path patterns. Supports `*` (single segment) and `**` (multi-segment).

#[serde(default, skip_serializing_if = "Option::is_none")]
pub allowed_paths: Option<Vec<String>>,
/// Optional allowed HTTP methods (e.g., `["GET", "POST"]`).

/// If `None`, all methods are allowed.

#[serde(default, skip_serializing_if = "Option::is_none")]
pub allowed_methods: Option<Vec<String>>,
/// Optional allowed ports. Defaults to `[443]` if not specified.

#[serde(default, skip_serializing_if = "Option::is_none")]
pub allowed_ports: Option<Vec<u16>>,
/// Whether TLS is required. Defaults to `true`.

#[serde(default = "default_true")]
pub require_tls: bool,
/// Whether subdomains of allowed domains are also allowed. Defaults to `false`.

#[serde(default)]
pub allow_subdomains: bool
}

Source line: 73.

proxy::DestinationBinding::new

Create a new destination binding for the given domains.

Errors

Returns an error if no domains are provided or validation fails.

pub fn new(allowed_domains: Vec<String>) -> ArsenalResult<Self>;

Source line: 106.

proxy::DestinationBinding::validate

Validate the destination binding configuration.

Errors

Returns an error if the configuration is invalid.

pub fn validate(&self) -> ArsenalResult<()>;

Source line: 124.

proxy::DestinationBinding::is_domain_allowed

Check if a given domain is allowed by this binding.

#[must_use]
pub fn is_domain_allowed(&self, domain: &str) -> bool;

Source line: 179.

proxy::DestinationBinding::is_method_allowed

Check if a given HTTP method is allowed by this binding.

#[must_use]
pub fn is_method_allowed(&self, method: &str) -> bool;

Source line: 195.

proxy::DestinationBinding::is_port_allowed

Check if a given port is allowed by this binding.

#[must_use]
pub fn is_port_allowed(&self, port: u16) -> bool;

Source line: 204.

proxy::DestinationBinding::is_path_allowed

Check if a given path matches the allowed path patterns.

Supports * (matches a single path segment) and ** (matches any number of segments).

#[must_use]
pub fn is_path_allowed(&self, path: &str) -> bool;

Source line: 216.

proxy::VariablePrefix

Variable prefix indicating the credential type.

Template variables follow the pattern {{PREFIX_NAME}}, where the prefix indicates the credential type and helps the proxy resolve the correct secret.

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum VariablePrefix {
    /// OAuth 2.0 token
    OAuth2,
    /// OAuth 1.0 token
    OAuth1,
    /// API key
    ApiKey,
    /// HTTP Basic authentication
    Basic,
    /// Bearer token
    Bearer,
    /// Client certificate
    Cert,
    /// Custom credential type
    Custom,
}

Source line: 232.

proxy::VariablePrefix::as_str

Get the string representation of this prefix.

#[must_use]
pub const fn as_str(&self) -> &'static str;

Source line: 252.

proxy::VariablePrefix::from_str_prefix

Parse a prefix from a string.

Errors

Returns an error if the string does not match a known prefix.

pub fn from_str_prefix(s: &str) -> ArsenalResult<Self>;

Source line: 269.

proxy::TemplateVariable

A parsed template variable from a proxy request.

Template variables are placeholders in proxy request URLs, headers, or bodies that the proxy replaces with actual credential values. Agents see only the placeholder name, never the resolved value.

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct TemplateVariable {
/// Full variable name (e.g., `OAUTH2_STRIPE_TOKEN`).

/// Must match `[A-Z][A-Z0-9_]{1,63}`.

pub name: String,
/// The credential type prefix parsed from the name.

pub prefix: VariablePrefix
}

Source line: 292.

proxy::TemplateVariable::new

Create a new template variable with validation.

Errors

Returns an error if the variable name is invalid.

pub fn new(name: impl Into<String>) -> ArsenalResult<Self>;

Source line: 306.

proxy::TemplateVariable::name

Get the variable name.

#[must_use]
pub fn name(&self) -> &str;

Source line: 315.

proxy::TemplateVariable::prefix

Get the credential type prefix.

#[must_use]
pub const fn prefix(&self) -> VariablePrefix;

Source line: 321.

proxy::parse_template_variables

Parse all template variables from a string containing {{VARIABLE}} placeholders.

Scans the input for {{...}} patterns and returns all valid template variables found. Invalid variable names inside {{}} are silently skipped.

#[must_use]
pub fn parse_template_variables(input: &str) -> Vec<TemplateVariable>;

Source line: 331.

proxy::validate_variable_name

Validate a template variable name.

Variable names must match [A-Z][A-Z0-9_]{1,63}.

Errors

Returns an error if the name is invalid.

pub fn validate_variable_name(name: &str) -> ArsenalResult<()>;

Source line: 360.

proxy::ProxyRequest

A proxy request from an agent to the broker.

The agent constructs this request using template variables instead of actual credentials. The broker resolves the variables, validates destination bindings, and forwards the assembled request.

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProxyRequest {
/// HTTP method (GET, POST, PUT, DELETE, etc.)

pub method: String,
/// Target URL (may contain `{{VARIABLE}}` placeholders)

pub url: String,
/// Optional HTTP headers (may contain `{{VARIABLE}}` placeholders)

#[serde(default, skip_serializing_if = "Option::is_none")]
pub headers: Option<BTreeMap<String, String>>,
/// Optional request body bytes

#[serde(default, skip_serializing_if = "Option::is_none")]
pub body: Option<Vec<u8>>,
/// Base64-encoded capability token authorizing this request

pub capability_token: String,
/// Optional timeout in milliseconds (default: 30000, max: 300000)

#[serde(default, skip_serializing_if = "Option::is_none")]
pub timeout_ms: Option<u64>
}

Source line: 408.

proxy::ProxyRequest::validate

Validate the proxy request structure.

Errors

Returns an error if the request is malformed.

pub fn validate(&self) -> ArsenalResult<()>;

Source line: 432.

proxy::ProxyRequest::effective_timeout_ms

Get the effective timeout in milliseconds.

#[must_use]
pub fn effective_timeout_ms(&self) -> u64;

Source line: 481.

proxy::ProxyRequest::extract_variables

Extract all template variables from the URL, headers, and body.

#[must_use]
pub fn extract_variables(&self) -> Vec<TemplateVariable>;

Source line: 489.

proxy::ProxyResponse

Response from the broker after proxying an API call.

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProxyResponse {
/// HTTP status code from the target API

pub status: u16,
/// Response headers (sanitized — credential headers stripped)

pub headers: BTreeMap<String, String>,
/// Response body bytes

pub body: Vec<u8>,
/// Metadata about how the proxy processed the request

pub proxy_metadata: ProxyMetadata
}

Source line: 518.

proxy::ProxyMetadata

Metadata about proxy request processing.

Included in every proxy response to give agents visibility into what happened without revealing credential values.

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProxyMetadata {
/// Names of variables that were resolved (never values)

pub variables_resolved: Vec<String>,
/// Whether the destination binding was verified

pub destination_verified: bool,
/// Whether the agent fingerprint was verified

pub fingerprint_verified: bool,
/// Status of human consent for credential usage

pub consent_status: ConsentStatus,
/// End-to-end proxy latency in milliseconds

pub latency_ms: u64,
/// Unique request ID for audit correlation

pub request_id: Uuid
}

Source line: 534.

proxy::ProxyMetadata::new

Create new proxy metadata for a request.

#[must_use]
pub fn new(request_id: Uuid) -> Self;

Source line: 552.

proxy::VariableResolutionTable

Maps template variable names to secret references.

The variable resolution table is maintained per-tenant and maps agent-visible variable names to the actual secrets they represent. This table is the bridge between the agent's view (template variables) and the broker's view (encrypted secrets).

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct VariableResolutionTable {

}

Source line: 573.

proxy::VariableResolutionTable::new

Create an empty resolution table.

#[must_use]
pub fn new() -> Self;

Source line: 581.

proxy::VariableResolutionTable::register

Register a variable-to-secret mapping.

Errors

Returns an error if the variable name is invalid or the table is full.

pub fn register(
        &mut self,
        variable_name: impl Into<String>,
        secret_ref: SecretRef,
    ) -> ArsenalResult<()>;

Source line: 590.

proxy::VariableResolutionTable::unregister

Remove a variable mapping. Returns true if the variable existed.

pub fn unregister(&mut self, variable_name: &str) -> bool;

Source line: 612.

proxy::VariableResolutionTable::resolve

Resolve a variable name to its secret reference.

#[must_use]
pub fn resolve(&self, variable_name: &str) -> Option<&SecretRef>;

Source line: 618.

proxy::VariableResolutionTable::variable_names

List all registered variable names.

#[must_use]
pub fn variable_names(&self) -> Vec<&str>;

Source line: 624.

proxy::VariableResolutionTable::len

Get the number of registered variables.

#[must_use]
pub fn len(&self) -> usize;

Source line: 630.

proxy::VariableResolutionTable::is_empty

Check if the table is empty.

#[must_use]
pub fn is_empty(&self) -> bool;

Source line: 636.

proxy::VariableResolutionTable::entries

Get a reference to the underlying entries.

#[must_use]
pub fn entries(&self) -> &BTreeMap<String, SecretRef>;

Source line: 642.

On this page