code wiki / (root) / nx_bearer_auth.nx

nx_bearer_auth.nx

buildroot/runtime/nx_bearer_auth.nx

4560 B133 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

bearer_auth.nx -- extract Bearer tokens from Authorization header. RFC 6750. The modern HTTP auth scheme for OAuth 2.0, JWT, API keys, and general \"the client holds a secret and presents it\" flows. Trivial algorithmically but worth isolating behind a helper so callers don't re-invent the case-insensitive prefix parse + whitespace handling every time. Authorization: Bearer eyJhbGciOi... ^^^^^^ ^^^^^^^^^^^^^ scheme token (opaque to HTTP) The token format itself (JWT / opaque random / signed session) is caller's concern -- we just peel the \"Bearer \" prefix. Invariants: BA1 Scheme match is case-insensitive per RFC 7235 ยง2.1. BA2 Token is returned as (offset, length) into the caller's buffer -- zero-alloc. BA3 Multiple whitespace tolerated between scheme and token (RFC permits 1 or more SP between credentials parts).

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_bearer_auth.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap bearer_auth_extract br_is_bearer br_lower bearer_auth_is_present sys_mmap ↻ bearer_auth_extract ↻

structs

none

consts

31const BR_ERR_FORMAT: i64 = -1
32const BR_ERR_SHORT: i64 = -2

functions

35func br_lower(b: i64) -> i64
called by 1: br_is_bearer
43func br_is_bearer(buf: *u8, off: i64, n: i64) -> i64
called by 1: bearer_auth_extract calls 1: br_lower
58func bearer_auth_extract(hdr: *u8, n: i64,
90func bearer_auth_is_present(hdr: *u8, n: i64) -> i64
called by 1: main calls 2: sys_mmapbearer_auth_extract
99func main() -> i64