code wiki / (root) / nx_basic_auth.nx

nx_basic_auth.nx

buildroot/runtime/nx_basic_auth.nx

6598 B201 linesdepth 2pulls 4 transitivereach 6 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

basic_auth.nx -- HTTP Basic Authentication (RFC 7617). Authorization header format: Authorization: Basic BASE64(username:password) The oldest HTTP auth scheme. Still everywhere: admin-panel login, IoT device configs, CI runner tokens, registry push, htpasswd-protected directories, internal tools. Combined with HTTPS it's adequate; on plain HTTP it's trivially sniffable. We ship encoder + decoder + Authorization-header matcher. Composes base64.nx. Invariants: BA1 Encoded output is \"Basic \" + base64(\"user:pass\"), one ASCII line. BA2 Decoder strips the leading \"Basic \" prefix case- insensitively per RFC 7617 ยง2. BA3 username + password round-trip byte-exact. BA4 Compare uses constant-time memcmp via ct.nx for the password half -- timing attacks on admin logins are real.

dependencies 3 imports · 2 importers

nx_syscalls.nx nx_base64.nx nx_ct.nx nx_basic_auth.nx nx_admin_login_flow.nx nx_login_gate.nx

imports: nx_syscalls.nxnx_base64.nxnx_ct.nx

imported by: nx_admin_login_flow.nxnx_login_gate.nx

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

main sys_mmap basic_auth_encode sys_mmap ↻ b64_encode b64_enc_char basic_auth_decode sys_mmap ↻ b64_decode b64_grab b64_dec_char basic_auth_verify ct_memcmp ct_eq

structs

none

consts

34const BA_ERR_FORMAT: i64 = -1
35const BA_ERR_SHORT: i64 = -2

functions

40func basic_auth_encode(username: *u8, u_len: i64,
called by 1: main calls 2: sys_mmapb64_encode
79func basic_auth_decode(hdr: *u8, n: i64,
143func basic_auth_verify(user_got: *u8, u_got_len: i64,
called by 1: main calls 1: ct_memcmp
167func main() -> i64