Skip to main content

auth_token_to_json

Function auth_token_to_json 

Source
fn auth_token_to_json(bytes: &[u8]) -> FieldValue
Expand description

Parse an authorization_token byte value into JSON.

Draft-12 Section 8.2.1.1 Figure 4 gives the Token the same four fields draft-11 does, with the first deciding which of the others are on the wire:

Token {
  Alias Type (i),
  [Token Alias (i),]
  [Token Type (i),]
  [Token Value (..)]
}

So the second varint is the Token Alias on DELETE (0x0), REGISTER (0x1) and USE_ALIAS (0x2), and the Token Type only on USE_VALUE (0x3). See crate::auth_token::TokenAliasType for the table and draft-13’s renderer for the branch this matches.

§What a value it cannot read renders as

The raw bytes, as fields::params and every other draft’s renderer do. Field extraction runs on a message that has already decoded, so it has no refusal to give — and no guarantee the bytes are a Token. setup_option_name asks one draft to render a setup parameter that arrived under another, which is the whole point of that function and the one place nothing upstream has validated anything. setup_option_name(12, &KeyValuePair { key: 0x03, value: KvpValue::Bytes(vec![]) }) is a public call with an empty value.