Skip to content

Release 3.6.1: admin auth hardening, API 21 compat, release docs - #3

Open
SmokeSlate wants to merge 1 commit into
mainfrom
release/v3.6.1
Open

Release 3.6.1: admin auth hardening, API 21 compat, release docs#3
SmokeSlate wants to merge 1 commit into
mainfrom
release/v3.6.1

Conversation

@SmokeSlate

Copy link
Copy Markdown
Owner

Gets v3.6.1 (versionCode 44) ready to ship.

⚠️ Deploy prerequisite — read before merging

The Worker no longer contains a hardcoded admin password hash. /admin returns 503 until both secrets are set:

wrangler secret put ADMIN_PASSWORD_HASH    # sha256 of admin password, 64 lowercase hex
wrangler secret put ADMIN_SESSION_SECRET   # random, 32+ chars

OPENROUTER_API_KEY stays optional (only /diagnose and /followup need it). Set these before deploying, or admin access breaks. api/README.md has a PowerShell snippet that generates both safely.

Note: the old hash constant remains in git history, so treat that password as burned and pick a new one.

Backend — admin auth hardening

  • Removed the hardcoded ADMIN_HASH; config now comes from secrets and fails closed when missing or malformed.
  • Sessions were previously "cookie value == password hash", so the cookie was the credential. Replaced with expiring HMAC-SHA256 signed tokens ({expiresAt}.{uuid}.{sig}), scoped Path=/admin, served no-store.
  • Password comparison is constant-time.
  • Pinned wrangler to 4.118.0.

Android — minSdk 21 correctness

build.gradle declares minSdk 21, but several APIs in use are newer. On a real API 21–25 device these would have thrown NoSuchMethodError at runtime:

  • Process.isAlive / waitFor(timeout) / destroyForcibly are API 26+ — added ProcessCompat.kt with polling equivalents.
  • ConnectivityManager.activeNetwork is API 23+ — added pre-M fallbacks in AdbManager and DiagnosticsCollector.
  • ACTION_MANAGE_UNKNOWN_APP_SOURCES is API 26+ — now guarded, falling back to security settings.
  • Swapped deprecated Resources.getColor for ContextCompat.getColor.

Docs

Documented the required secrets, and corrected AGENTS.md sections that had drifted from the code: the route table (routes are path-style now, plus /diagnose, /followup, /admin/logout, /admin/bulk-delete), the admin-auth description, and the AI section (/aifix uses Pollinations; /diagnose uses OpenRouter).

Also ignored wrangler local state, dry-run output, and tooling scratch dirs that were sitting untracked.

Verification

Check Result
assembleRelease + assembleDebug ✅ pass
lintRelease ✅ 0 errors (46 warnings, all pre-existing)
npm run check (syntax + tests + dry-run) ✅ pass
Worker auth tests ✅ 3/3

New tests cover session issuance without leaking the hash, tampered-session rejection, and fail-closed-when-unconfigured.

Committed APK artifacts were rebuilt so they match the final source.

🤖 Generated with Claude Code

Backend (Cloudflare Worker):
- Remove the hardcoded ADMIN_HASH constant. Admin auth now requires the
  ADMIN_PASSWORD_HASH and ADMIN_SESSION_SECRET secrets and fails closed
  (503) when either is missing or malformed.
- Replace the "cookie value equals password hash" scheme with expiring
  HMAC-SHA256 signed session tokens, scoped to Path=/admin and served
  no-store. Password comparison is constant-time.
- Add node --test coverage for session issuance, tampered-session
  rejection, and fail-closed behaviour, plus an `npm run check` gate.
- Pin wrangler to 4.118.0.

Android app:
- Add ProcessCompat helpers so process liveness, timed waits, and
  termination work on the declared minSdk 21 (Process.isAlive,
  waitFor(timeout), and destroyForcibly are all API 26+).
- Guard ConnectivityManager.activeNetwork (API 23+) in AdbManager and
  DiagnosticsCollector with pre-M fallbacks.
- Guard ACTION_MANAGE_UNKNOWN_APP_SOURCES (API 26+) in HomeActivity.
- Replace deprecated Resources.getColor with ContextCompat.getColor.
- Annotate the ADB-granted protected permissions in the manifest.

Docs and hygiene:
- Document the required Worker secrets in wrangler.toml and AGENTS.md,
  and correct the now-stale route table, admin-auth and AI-endpoint
  sections.
- Ignore wrangler local state, dry-run output, and tooling scratch.

Verified: assembleRelease + assembleDebug succeed, lintRelease reports
0 errors, and `npm run check` passes (3/3 tests, worker dry-run clean).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant