- Add axum middleware layer for auth on all routes (pages, API, WS,
static files). Browser now shows native login dialog on 401.
- Return WWW-Authenticate: Basic realm="ARZ Web Helper" with 401
- WebSocket auth via ?token= query param (checked in middleware)
- Remove per-handler auth checks — middleware covers everything
- Rewrite auth.rs with Mutex<AuthState> instead of OnceLock<String>
to support secret regeneration on reset
- Add rgl_auth_reset FFI: clears credentials + regenerates secret
- Fix imgui admin panel: pass admin_state instead of {} to admin_render
- Admin Auth tab: add Disable + Reset buttons
- Fix web ui_page.html: inputs use oninput (no re-render on type),
collect all input values before POST
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Auth system (new rust_core/src/auth.rs):
- Secret generated at startup, stored in /data/data/ or /sdcard/Android/data/
(not accessible to other apps). Never exposed via FFI.
- Credentials encrypted with secret, stored in separate `auth` DB table
(modules can't access through kv API)
- HTTP middleware checks Basic auth or Bearer token on /api/* and /ws
- Admin panel Auth tab for setting/clearing credentials
- FFI: rgl_auth_init, rgl_auth_set, rgl_auth_clear, rgl_auth_enabled
Integration tests (28 total, was 7):
- bridge.rs: request/response cycle, unique IDs, timeout, event broadcast
- events.rs: win1251 roundtrip, color parsing, HTML escaping
- auth.rs: XOR roundtrip, secret generation, Basic/Bearer auth
Other fixes:
- Make cjson a hard requirement (remove broken fallback JSON encoder)
- Replace io.popen('ls') with pcall-wrapped list_module_dirs() helper
- Fix console serialize: add local, move above M.init()
- Clear all medium tasks from TASKS.md
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Sandbox each module via setfenv(): writes go to per-module environment,
reads proxy to _G. Modules can no longer accidentally overwrite each
other's globals or framework internals. Sandbox is GC'd on unload.
- Add dynamic window registry (fw.register_window/toggle_window/
show_window/hide_window) so modules can create imgui windows without
editing the framework. Replace hardcoded BTC OnFrame with generic handler.
- Make admin_visible local (was global)
- Fix console serialize: add local, move above M.init() for correct scoping
- Expand .gitignore: target/, build/, *.so, *.log, rgl_data.db, env.fish
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add lock_or_recover() helper in bridge.rs and server.rs to handle
poisoned mutexes gracefully instead of panicking
- Replace expect() in db::init() with proper error logging and early
return so DB init failures don't crash the process
- Replace Response::builder().unwrap() with tuple .into_response()
pattern in server.rs HTTP handlers
- Handle condvar poison in bridge::request_lua_exec_sync_wait
- All errors now logged via logging::log() for visibility in admin panel
- Remove unused `use body::Body` import
- Zero unwrap()/expect() remaining outside #[cfg(test)]
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 day ago
14 changed files with 873 additions and 222 deletions
@ -12,59 +12,13 @@ Prioritized backlog of issues, improvements, and feature ideas.
## High
## High
### Add proper .gitignore
*No high issues currently.*
Current `.gitignore` only has `more_modules`. Missing:
- `rust_core/target/`
- `*.so`
- `rgl_data.db`
- `*.log`
- `.DS_Store`
### Create build script
No Makefile or build automation exists. Need a script for:
- Cross-compile Rust for aarch64-linux-android
- Deploy .so to device via ADB
- Optional: rebuild on file change
### Improve Rust error handling
50+ `unwrap()` calls across Rust codebase. Key areas:
- `bridge.rs`: mutex locks can panic on poisoning — use `unwrap_or_else()` with recovery
- `db.rs`: 30+ unwrap/unwrap_or_default — silent failures on DB errors
- `server.rs`: 15+ unwraps in HTTP handlers
Should introduce proper error types (thiserror crate) or at minimum `unwrap_or_else()` with logging.
### Silent JSON parse failures in db.rs
`execute_batch()` returns `"[]"` on JSON parse error without logging. Should log the error for debugging.
---
---
## Medium
## Medium
### Fix BTC module global state
*No medium issues currently.*
`more_modules/btc/init.lua` uses `btc_visible = false` as a global variable (for mimgui OnFrame). Should be moved to a proper module state mechanism to avoid global namespace pollution.
### Implement WebSocket backpressure
`bridge.rs` broadcast channel has capacity 256. Events are silently dropped when full. Should either increase capacity, add warning logging, or implement backpressure.
### Improve fallback JSON encoder
`rgl_framework.lua` fallback JSON decoder only handles flat `{"key":"value"}` — fails on nested objects, arrays, numbers, booleans. Since cjson is always expected to be present, consider making it a hard requirement instead of silently degrading.
### Add integration tests
Only `db.rs` has tests (6 batch operation tests). Missing:
- Bridge request/response cycle
- Event system overflow/blocking
- HTTP handler edge cases
- Module loading/unloading
- Win-1251 encoding conversion
### Module loading error handling
`load_all_modules()` uses `io.popen('ls ...')` which can fail if directory is deleted between listing and loading. Use `pcall(io.open)` instead.
### Add auth/CORS for web API
Currently any network client can call all APIs. Consider at minimum:
- Bind to localhost only (or configurable)
- Basic auth token
- CORS headers for web clients
---
---
@ -76,9 +30,6 @@ No protection against API spam. Could add simple per-endpoint rate limits.
### Add request/response logging middleware
### Add request/response logging middleware
No HTTP access logging in Rust. Add optional access log for debugging API calls.
No HTTP access logging in Rust. Add optional access log for debugging API calls.
### Optimize broadcast channel capacity
Current 256 capacity is arbitrary. Profile actual event rates and set appropriately.
### Add module versioning
### Add module versioning
No way to track which version of a module is loaded. Could add `M.version` field and display in admin panel.
No way to track which version of a module is loaded. Could add `M.version` field and display in admin panel.