Skip to main content

parse_token_entry

Function parse_token_entry 

Source
pub fn parse_token_entry(
    s: &str,
) -> Result<(BearerString, TokenScope), ScopeParseError>
Expand description

Parse a single entry of the TENSOR_WASM_API_TOKENS allowlist.

Accepted shapes (after trimming surrounding whitespace):

  • token — legacy bare bearer. Returns TokenScope::all.
  • token:tenant=* — explicit wildcard.
  • token:tenant=1,2,3 — explicit allowlist.

The parser is intentionally strict on the scoped form: an empty tenant list, an unknown key, or a tenant id that does not parse as a u64 returns an Err. The caller decides whether to ignore (skip the entry) or surface the error — see parse_tokens_env for the policy applied at startup.