pub struct KernelPublishTokens { /* private fields */ }Expand description
Allowlist of bearer tokens permitted to call POST /kernels.
Internally stores the crate::rate_limit::TokenId of each
allowlisted bearer (the xxhash64 digest used elsewhere for rate
limiting), NOT the raw token string. Keeping TokenIds here means
the value can flow through axum::Extension and tracing without
risking the raw secret leaking into a span attribute or audit
record, and allows() reduces to a hash-set lookup.
The list is empty by default — that is the safe posture: with no
publish-scoped tokens configured, POST /kernels returns
403 kernel_publish_scope_required. Dev mode (empty
TENSOR_WASM_API_TOKENS) is even stricter: the publish handler
rejects outright with kernel_publish_disabled_in_dev_mode to deny
the unauthenticated-attacker path the security review flagged.
Sourced from ENV_KERNEL_PUBLISH_TOKENS at server startup; tests
drive it directly via KernelPublishTokens::from_tokens so they
do not poison the process environment.
Implementations§
Source§impl KernelPublishTokens
impl KernelPublishTokens
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Parse the allowlist from ENV_KERNEL_PUBLISH_TOKENS. Splits on
,, trims surrounding whitespace, drops empty entries, hashes
each remaining entry into a crate::rate_limit::TokenId. Unset
/ empty env var yields the empty allowlist — every POST /kernels is rejected with kernel_publish_scope_required.
Sourcepub fn from_raw(raw: &str) -> Self
pub fn from_raw(raw: &str) -> Self
Parse a comma-separated string as if it were the env variable. Public for the explicit-construction path used by tests.
Sourcepub fn from_tokens<I, S>(iter: I) -> Self
pub fn from_tokens<I, S>(iter: I) -> Self
Construct from an iterator of raw bearer-token strings. Used by integration tests that drive the publish-scope path directly.
Trait Implementations§
Source§impl Clone for KernelPublishTokens
impl Clone for KernelPublishTokens
Source§fn clone(&self) -> KernelPublishTokens
fn clone(&self) -> KernelPublishTokens
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for KernelPublishTokens
impl Debug for KernelPublishTokens
Source§impl Default for KernelPublishTokens
impl Default for KernelPublishTokens
Source§fn default() -> KernelPublishTokens
fn default() -> KernelPublishTokens
Auto Trait Implementations§
impl Freeze for KernelPublishTokens
impl RefUnwindSafe for KernelPublishTokens
impl Send for KernelPublishTokens
impl Sync for KernelPublishTokens
impl Unpin for KernelPublishTokens
impl UnsafeUnpin for KernelPublishTokens
impl UnwindSafe for KernelPublishTokens
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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