pub struct TokenExchangeAuthProvider { /* private fields */ }Expand description
Auth provider that exchanges a subject token for a user-scoped delegated token via RFC 8693 Token Exchange.
Implementations§
Source§impl TokenExchangeAuthProvider
impl TokenExchangeAuthProvider
Sourcepub fn new(
exchange_url: impl Into<String>,
client_id: impl Into<String>,
client_secret: impl Into<String>,
agent_token: impl Into<String>,
) -> Self
pub fn new( exchange_url: impl Into<String>, client_id: impl Into<String>, client_secret: impl Into<String>, agent_token: impl Into<String>, ) -> Self
Construct a provider without validating the exchange URL.
Backward-compatible constructor. For new code prefer
TokenExchangeAuthProvider::try_new which validates the URL
synchronously (scheme + literal-IP) and returns an Err for obvious
misconfigurations (file://, http://127.0.0.1, etc.) instead of
silently storing them. We log a tracing::error! here when the URL
fails the sync check so misconfigured deployments are still loud,
but defer to the redirect-policy defense-in-depth at request time.
Sourcepub fn try_new(
exchange_url: impl Into<String>,
client_id: impl Into<String>,
client_secret: impl Into<String>,
agent_token: impl Into<String>,
) -> Result<Self, Error>
pub fn try_new( exchange_url: impl Into<String>, client_id: impl Into<String>, client_secret: impl Into<String>, agent_token: impl Into<String>, ) -> Result<Self, Error>
Validating constructor: returns Err if the exchange URL fails the
synchronous SSRF check (scheme allowlist + literal-IP blocklist).
SECURITY (F-MCP-1): use this when you can propagate the error to the caller. The redirect-policy and HTTPS enforcement still apply to any URL accepted here, so a hostile DNS rebind cannot leak the token.
Sourcepub fn with_tenant_id(self, tenant_id: Option<String>) -> Self
pub fn with_tenant_id(self, tenant_id: Option<String>) -> Self
Set the NHI tenant ID for automatic client_credentials agent token fetch.
Sourcepub fn with_scopes(self, scopes: Vec<String>) -> Self
pub fn with_scopes(self, scopes: Vec<String>) -> Self
Set the OAuth scopes for the client_credentials agent token grant.
Trait Implementations§
Source§impl AuthProvider for TokenExchangeAuthProvider
impl AuthProvider for TokenExchangeAuthProvider
Source§fn auth_header_for<'a>(
&'a self,
user_id: &'a str,
tenant_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, Error>> + Send + 'a>>
fn auth_header_for<'a>( &'a self, user_id: &'a str, tenant_id: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, Error>> + Send + 'a>>
None if no auth is needed.