Skip to main content

is_valid_audience

Function is_valid_audience 

Source
pub fn is_valid_audience(aud: &str) -> bool
Expand description

true if aud is a valid audience name: [A-Za-z0-9_-]{1,255}, checked in bytes – the ASCII-only charset makes byte length and char length agree for every value that can pass, so this doubles as the length check the ingestion_api_keys.audience VARCHAR(255) column enforces on the SQL side.

An audience is an opaque label on data, not a principal encoding: this charset makes an email (@, .) or a user:/group:-prefixed value (:) unrepresentable, on purpose – see AudienceGrants for why there is no derivation from a caller’s identity to replace it with.

Deliberately not normalizing: no case folding, no trimming. The value is stored and compared verbatim, which is what makes uniqueness meaningful – team-alpha and Team-Alpha are two audiences, and neither is a typo the system silently repairs into the other.