bearer_auth.nx
buildroot/runtime/bearer_auth.nx
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
imports: syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 25 | const BR_ERR_FORMAT: i64 = -1 |
| 26 | const BR_ERR_SHORT: i64 = -2 |
functions
| 29 | func br_lower(b: i64) -> i64 {
called by 1: br_is_bearer |
| 37 | func br_is_bearer(buf: *u8, off: i64, n: i64) -> i64 { |
| 52 | func bearer_auth_extract(hdr: *u8, n: i64, |
| 84 | func bearer_auth_is_present(hdr: *u8, n: i64) -> i64 { |
| 93 | func main() -> i64 { |