code wiki / (root) / bearer_auth.nx

bearer_auth.nx

buildroot/runtime/bearer_auth.nx

4433 B127 linesdepth 3pulls 3 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

syscalls.nx bearer_auth.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

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

main bearer_auth_extract br_is_bearer br_lower bearer_auth_is_present bearer_auth_extract ↻

structs

none

consts

25const BR_ERR_FORMAT: i64 = -1
26const BR_ERR_SHORT: i64 = -2

functions

29func br_lower(b: i64) -> i64 {
called by 1: br_is_bearer
37func br_is_bearer(buf: *u8, off: i64, n: i64) -> i64 {
called by 1: bearer_auth_extract calls 1: br_lower
52func bearer_auth_extract(hdr: *u8, n: i64,
84func bearer_auth_is_present(hdr: *u8, n: i64) -> i64 {
called by 1: main calls 1: bearer_auth_extract
93func main() -> i64 {