Skip to main content

parse_tokens_env

Function parse_tokens_env 

Source
pub fn parse_tokens_env(env_value: &str) -> ParsedTokens
Expand description

Parse the TENSOR_WASM_API_TOKENS env-var value into a map of bearer → scope, plus a count of legacy (bare) entries that were coerced to the wildcard scope.

The input may mix the two entry shapes freely. Splitting is two-pass:

  1. Split on commas to obtain raw fragments.
  2. Walk fragments left to right, re-joining any fragment that does not contain a : and follows an entry whose scope clause was tenant= (a continuation of the tenant list).

Entries that fail parse_token_entry are dropped with a tracing::warn! so a malformed entry never causes the gateway to refuse to start. The remaining valid entries are returned in ParsedTokens.