nx_wiki_admin_wiring.nx
buildroot/runtime/wiki/nx_wiki_admin_wiring.nx
about
nx_wiki_admin_wiring.nx -- V-MODAUTH-7 per-site wiring for wiki admin routes.
REWRITTEN 2026-05-27 from V1 cookie-based wiring to V-MODAUTH-6
SEALED API per NISHI_MODERN_AUTH_CHARTER §8. Composes
hub/nx_modern_auth_flow (V-MODAUTH-6) which itself composes
hub/nx_no_cookie_session (V-MODAUTH-5).
NO COOKIES. NO Set-Cookie. NO Cookie: reads. Per C1 cardinal.
Per-request flow (the hot path):
1. Caller extracts X-Nishi-Session header from HTTP request
via nx_http_header_find
2. Caller base64-decodes the header value to a 152-byte binary
session token
3. Caller passes (NxAuthContext + token bytes + now_unix_s) to
nx_wiki_admin_handle
4. nx_wiki_admin_handle calls nx_modern_auth_validate_session
5. On success: emit 200/302 to protected content
On failure: emit 401 with hint "POST passphrase to /wiki/admin/login"
COMPOSES per "avoid duplicate primitives":
hub/nx_modern_auth_flow V-MODAUTH-6 SEALED §8 API
nx_http_header_find HTTP header extraction
COMPOSED BY:
wiki/nx_wiki_routes.nx dispatcher (updated to pass *NxAuthContext)
SPEC REFERENCES:
NISHI_MODERN_AUTH_CHARTER §8 SEALED 5-fn API
NISHI_MODERN_AUTH_CHARTER §9.1 nishifamily.com wiring example
V2 (2026-06-10): POST /wiki/admin/login is LIVE -- OPAQUE (RFC 9807, KAT-gated)
+ argon2id KSF + account store + Ed25519 session mint. Flow:
POST /wiki/admin/login body "handle=<h>&passphrase=<p>" (form-urlencoded)
-> nx_modern_auth_login -> 200 {"token":"<base64 152B>"} | 401
GET /wiki/admin/* X-Nishi-Session: <base64 token> -> 200 | 401
The 503 LOGIN_NOT_READY path remains ONLY for an unarmed context (no
account store / oprf_seed wired at boot) -- honest, not a pretend-stub.
Admin REGISTRATION is out-of-band (ops provisioning via
nx_modern_auth_register; no public register endpoint on the admin realm).
dependencies 4 imports · 2 importers
imports: nx_syscalls.nxnx_http_header_find.nxnx_base64.nxnx_modern_auth_flow.nx
imported by: nx_wiki_login_live_gate.nxnx_wiki_routes.nx
structs
| none |
consts
| 48 | const NX_WAW_OK: i64 = 0 |
| 49 | const NX_WAW_BAD_INPUT: i64 = 1420 |
| 50 | const NX_WAW_BUF_OVERFLOW: i64 = 1421 |
| 51 | const NX_WAW_AUTH_FAILED: i64 = 1422 |
| 52 | const NX_WAW_LOGIN_NOT_READY: i64 = 1423 // /wiki/admin/login waits for V-MODAUTH-2/4 |
| 55 | const NX_WAW_MAX_HEADER_SCAN_BYTES: i64 = 8192 |
| 56 | const NX_WAW_RESP_CAP: i64 = 4096 |
| 57 | const NX_WAW_HDR_SESSION_NAME_N: i64 = 15 // "X-Nishi-Session" (was 16 = NEVER matched; |
| 61 | const NX_WAW_METHOD_GET: i64 = 1 |
| 62 | const NX_WAW_METHOD_POST: i64 = 2 |
functions
| 66 | func _waw_hdr_session_name() -> *u8 { return "X-Nishi-Session" as *u8 } |
| 68 | func _waw_append(resp_buf: *u8, out_off: *i64, resp_cap: i64, |
| 81 | func _waw_append_z(resp_buf: *u8, out_off: *i64, resp_cap: i64, |
| 99 | func _waw_emit_401(resp_buf: *u8, out_off: *i64, resp_cap: i64) -> i64 |
| 106 | func _waw_emit_authed_200(resp_buf: *u8, out_off: *i64, resp_cap: i64) -> i64 |
| 113 | func _waw_emit_login_not_ready(resp_buf: *u8, out_off: *i64, resp_cap: i64) -> i64 |
| 120 | func _waw_emit_json_kv(resp_buf: *u8, out_off: *i64, resp_cap: i64, |
| 149 | func _waw_emit_login_ok(resp_buf: *u8, out_off: *i64, resp_cap: i64, called by 2: _waw_handle_login_post_waw_handle_refresh_post calls 3: sys_mmapb64_encode_waw_emit_json_kv |
| 159 | func _waw_emit_login_401(resp_buf: *u8, out_off: *i64, resp_cap: i64) -> i64 called by 3: _waw_handle_login_post_waw_handle_recover_post_waw_handle_refresh_post calls 1: _waw_append_z |
| 169 | func _waw_hex_nib(c: i64) -> i64 called by 1: _waw_urldecode |
| 177 | func _waw_urldecode(src: *u8, n: i64, out: *u8, out_cap: i64) -> i64 |
| 201 | func _waw_form_field(body: *u8, body_n: i64, |
| 236 | func _waw_content_length(http_req_buf: *u8, http_headers_end: i64) -> i64 |
| 258 | func _waw_handle_login_post( |
| 315 | func _waw_handle_recover_post( |
| 385 | func _waw_handle_refresh_post( |
| 430 | func _waw_path_eq(url_path: *u8, url_path_n: i64, want: *u8, want_n: i64) -> i64 called by 1: nx_wiki_admin_handle |
| 459 | func nx_wiki_admin_handle( |