pub struct AuthProxyConfig {
pub upstream: Url,
pub secret_upstream: Option<Url>,
pub admin_key: String,
pub max_body_bytes: usize,
}Expand description
Configuration of the proxy. Its Debug output never shows the admin key.
§Examples
use ironflow_auth_proxy::AuthProxyConfig;
let config = AuthProxyConfig::new("0123456789abcdef0123456789abcdef");
assert_eq!(config.upstream.as_str(), "https://api.anthropic.com/");
assert!(config.secret_upstream.is_none());
assert!(!format!("{config:?}").contains("0123456789abcdef"));Fields§
§upstream: UrlWhere requests are relayed. Always https://api.anthropic.com in the binary.
secret_upstream: Option<Url>Where /r/<host>/ requests are relayed instead of https://<host>.
Always None in the binary.
admin_key: StringKey protecting the admin API.
max_body_bytes: usizeLargest request body relayed, in bytes.
Implementations§
Source§impl AuthProxyConfig
impl AuthProxyConfig
Sourcepub fn new(admin_key: &str) -> Self
pub fn new(admin_key: &str) -> Self
Configuration relaying to DEFAULT_UPSTREAM with the given admin key.
§Panics
Panics if admin_key is shorter than MIN_ADMIN_KEY_LEN.
§Examples
See AuthProxyConfig.
Sourcepub fn with_upstream(self, upstream: Url) -> Self
pub fn with_upstream(self, upstream: Url) -> Self
Relay to another upstream. For tests only: the binary never calls
it, so a deployed proxy only reaches api.anthropic.com.
§Examples
use ironflow_auth_proxy::AuthProxyConfig;
use url::Url;
let config = AuthProxyConfig::new("0123456789abcdef0123456789abcdef")
.with_upstream(Url::parse("http://127.0.0.1:9000")?);
assert_eq!(config.upstream.port(), Some(9000));Sourcepub fn with_secret_upstream(self, upstream: Url) -> Self
pub fn with_secret_upstream(self, upstream: Url) -> Self
Relay every /r/<host>/ request to upstream instead of
https://<host>. The host allowlist is still checked on <host>.
For tests only: the binary never calls it, so a deployed proxy
only reaches the allowlisted hosts, over https.
§Examples
use ironflow_auth_proxy::AuthProxyConfig;
use url::Url;
let config = AuthProxyConfig::new("0123456789abcdef0123456789abcdef")
.with_secret_upstream(Url::parse("http://127.0.0.1:9001")?);
assert_eq!(config.secret_upstream.and_then(|url| url.port()), Some(9001));Trait Implementations§
Source§impl Clone for AuthProxyConfig
impl Clone for AuthProxyConfig
Auto Trait Implementations§
impl Freeze for AuthProxyConfig
impl RefUnwindSafe for AuthProxyConfig
impl Send for AuthProxyConfig
impl Sync for AuthProxyConfig
impl Unpin for AuthProxyConfig
impl UnsafeUnpin for AuthProxyConfig
impl UnwindSafe for AuthProxyConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more