[PR #8829] [MERGED] feat(access): make the admin secret in the app; signed-in browsers use installed agents #8833

Closed
opened 2026-11-07 17:40:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8829
Author: @Gunterlie
Created: 11/4/2026
Status: ✅ Merged
Merged: 11/4/2026
Merged by: @Gunterlie

Base: staging ← Head: feat/admin-secret-in-app


📝 Commits (5)

  • bba080f feat(access): make the admin secret in the app; signed-in browsers use installed agents
  • 5eae2d8 fix(access): review fixes for the in-app admin secret
  • 149275a fix(access): name only .env in the no-secret refusal when loopback needs the secret
  • 536329c fix(access): let the owner remove an unused app admin secret while .env wins
  • d112da1 test(access): expect adminSecretSource and adminSecretStored in the status

📊 Changes

18 files changed (+342 additions, -34 deletions)

View changed files

📝 .env.example (+1 -0)
📝 README.md (+1 -1)
📝 docs/CONFIGURATION.md (+2 -2)
📝 docs/REMOTE_ACCESS.md (+25 -7)
📝 docs/TROUBLESHOOTING.md (+2 -2)
📝 docs/connections/local-model.md (+1 -1)
📝 packages/client/src/components/diagnostics/use-access-warning-banner.tsx (+4 -0)
📝 packages/client/src/components/panels/SettingsPanel.tsx (+8 -1)
📝 packages/client/src/components/panels/settings/AccessStatusSettings.tsx (+108 -3)
📝 packages/client/src/lib/api-client.ts (+1 -1)
📝 packages/client/src/localization/locales/en.json (+15 -1)
📝 packages/server/src/config/login-credential.ts (+59 -4)
📝 packages/server/src/middleware/ip-allowlist.ts (+2 -3)
📝 packages/server/src/middleware/privileged-gate.ts (+8 -7)
📝 packages/server/src/routes/access-status.routes.ts (+26 -0)
📝 packages/server/src/services/capability-packages/capability-route-registration.service.ts (+8 -1)
📝 scripts/regressions/access-status.regression.ts (+2 -0)
📝 scripts/regressions/remote-login.regression.ts (+69 -0)

📄 Description

Important

Contributions target staging.

Linked issue

No linked issue. A maintainer asked for this change directly (planned work, no separate feature request).

Why this change

Remote devices need the admin secret for risky actions (backups, data clear, updates, installs). Until now the only way to get one was to edit ADMIN_SECRET in the server .env. The app login can already be set in the app, so the admin secret should work the same way.

Also, opening an installed agent (for example a Home screen agent) from a signed-in phone failed without the admin secret, because every package route sat behind the admin gate. Installing a package already needs the secret, so its routes are trusted code; normal use should only need the login.

What changed

  • Make the admin secret in the app. New POST/DELETE /api/access/admin-secret. Only a caller that already has admin rights may use them: this computer (loopback, unless MARINARA_REQUIRE_ADMIN_SECRET_ON_LOOPBACK=true) or a device that sends the current secret. A browser that is only signed in cannot, so a stolen session cannot take over the risky actions.
  • The server makes a readable 24-symbol secret (~119 bits, same alphabet as the setup code) and keeps only its SHA-256 hash in DATA_DIR/.admin-secret.json (0600, atomic write, re-read on change like the login file). Case, spaces and dashes do not matter when typing it. ADMIN_SECRET in .env wins; DELETE clears the app file even then, so an old app secret cannot come back when .env is cleared.
  • privileged-gate.ts and the access policy use the new getAdminSecretSource() / matchesAdminSecret(); /api/access/status reports adminSecretSource.
  • Settings → Advanced → Admin Access: Make admin secret, Replace admin secret and Remove admin secret (with confirm dialogs). The new secret is shown once and saved in this browser. Devices that cannot change it (Docker host browser without a secret, signed-in remote without the secret) see a pointer to .env instead. .env-managed secrets show a note.
  • Installed package routes accept a signed-in browser (signedIn: true in capability-route-registration.service.ts). Install, update and removal routes still need the admin secret.
  • 403 message, client hint and settings.accessStatus.secretNotSet mention the in-app path.
  • Docs: REMOTE_ACCESS.md (Admin Access section rewritten with docs-writing rules), CONFIGURATION.md, TROUBLESHOOTING.md, connections/local-model.md, README.md, .env.example.

Validation

Commands run locally:

  • pnpm check (passes; existing unrelated lint warnings only)
  • pnpm localization:check
  • Regressions: remote-login (new admin-secret block: signed-in browser refused, loopback makes a readable secret, only the hash is saved, loose typing works, rotation kills the old secret, new secret works remotely, .env wins with 409, DELETE under .env clears the file), access-policy, lockdown-setup-security, capability-internal-route, capability-package-lifecycle, docker-proxy-auth, loopback-proxy-auth-security, multiplayer-control-security.

Review: local CodeRabbit could not run (CLI not authenticated on this machine). A Marinara reviewer agent found nothing blocking; its 4 low/medium findings (Docker path, stale .env-only texts, old app secret reviving after .env removal, README) are fixed in the second commit.

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Not done yet. Please verify:

  • On the server's own computer: Settings → Advanced → Admin Access → Make admin secret shows the secret once and fills the box; a privileged action (for example a backup) then works from a phone after typing the secret there.
  • Replace admin secret on a remote device that has the secret: the old secret stops working everywhere.
  • Remove admin secret: remote privileged actions fail again with the updated hint.
  • With ADMIN_SECRET in .env: Admin Access shows the .env note, no buttons.
  • Docker: host browser without a secret sees the .env pointer, not the buttons.
  • From a phone signed in with the login and no admin secret: opening an installed Home screen agent works; installing or removing an agent still asks for the secret.
  • Light/dark mode and 390 px width of the Admin Access section.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened

Follow-up for translations: #8830

  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

No screenshots yet (see manual verification).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8829 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 11/4/2026 **Status:** ✅ Merged **Merged:** 11/4/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `feat/admin-secret-in-app` --- ### 📝 Commits (5) - [`bba080f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bba080fe875fb3738c30c54d1eac322db7e882da) feat(access): make the admin secret in the app; signed-in browsers use installed agents - [`5eae2d8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5eae2d8e994fff5cd07e6a5e2f5d47a44bff36d6) fix(access): review fixes for the in-app admin secret - [`149275a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/149275a5d96acee4a2c6bcf01497a524d22352e2) fix(access): name only .env in the no-secret refusal when loopback needs the secret - [`536329c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/536329c120a22fb883f58e1b6678d05680e89487) fix(access): let the owner remove an unused app admin secret while .env wins - [`d112da1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d112da18dba859b8763e7d31d0fc78da525d9146) test(access): expect adminSecretSource and adminSecretStored in the status ### 📊 Changes **18 files changed** (+342 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `.env.example` (+1 -0) 📝 `README.md` (+1 -1) 📝 `docs/CONFIGURATION.md` (+2 -2) 📝 `docs/REMOTE_ACCESS.md` (+25 -7) 📝 `docs/TROUBLESHOOTING.md` (+2 -2) 📝 `docs/connections/local-model.md` (+1 -1) 📝 `packages/client/src/components/diagnostics/use-access-warning-banner.tsx` (+4 -0) 📝 `packages/client/src/components/panels/SettingsPanel.tsx` (+8 -1) 📝 `packages/client/src/components/panels/settings/AccessStatusSettings.tsx` (+108 -3) 📝 `packages/client/src/lib/api-client.ts` (+1 -1) 📝 `packages/client/src/localization/locales/en.json` (+15 -1) 📝 `packages/server/src/config/login-credential.ts` (+59 -4) 📝 `packages/server/src/middleware/ip-allowlist.ts` (+2 -3) 📝 `packages/server/src/middleware/privileged-gate.ts` (+8 -7) 📝 `packages/server/src/routes/access-status.routes.ts` (+26 -0) 📝 `packages/server/src/services/capability-packages/capability-route-registration.service.ts` (+8 -1) 📝 `scripts/regressions/access-status.regression.ts` (+2 -0) 📝 `scripts/regressions/remote-login.regression.ts` (+69 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. ## Linked issue No linked issue. A maintainer asked for this change directly (planned work, no separate feature request). ## Why this change Remote devices need the admin secret for risky actions (backups, data clear, updates, installs). Until now the only way to get one was to edit `ADMIN_SECRET` in the server `.env`. The app login can already be set in the app, so the admin secret should work the same way. Also, opening an installed agent (for example a Home screen agent) from a signed-in phone failed without the admin secret, because every package route sat behind the admin gate. Installing a package already needs the secret, so its routes are trusted code; normal use should only need the login. ## What changed - **Make the admin secret in the app.** New `POST`/`DELETE /api/access/admin-secret`. Only a caller that already has admin rights may use them: this computer (loopback, unless `MARINARA_REQUIRE_ADMIN_SECRET_ON_LOOPBACK=true`) or a device that sends the current secret. A browser that is only signed in cannot, so a stolen session cannot take over the risky actions. - The server makes a readable 24-symbol secret (~119 bits, same alphabet as the setup code) and keeps only its SHA-256 hash in `DATA_DIR/.admin-secret.json` (0600, atomic write, re-read on change like the login file). Case, spaces and dashes do not matter when typing it. `ADMIN_SECRET` in `.env` wins; `DELETE` clears the app file even then, so an old app secret cannot come back when `.env` is cleared. - `privileged-gate.ts` and the access policy use the new `getAdminSecretSource()` / `matchesAdminSecret()`; `/api/access/status` reports `adminSecretSource`. - **Settings → Advanced → Admin Access:** **Make admin secret**, **Replace admin secret** and **Remove admin secret** (with confirm dialogs). The new secret is shown once and saved in this browser. Devices that cannot change it (Docker host browser without a secret, signed-in remote without the secret) see a pointer to `.env` instead. `.env`-managed secrets show a note. - **Installed package routes accept a signed-in browser** (`signedIn: true` in `capability-route-registration.service.ts`). Install, update and removal routes still need the admin secret. - 403 message, client hint and `settings.accessStatus.secretNotSet` mention the in-app path. - Docs: `REMOTE_ACCESS.md` (Admin Access section rewritten with docs-writing rules), `CONFIGURATION.md`, `TROUBLESHOOTING.md`, `connections/local-model.md`, `README.md`, `.env.example`. ## Validation Commands run locally: - `pnpm check` (passes; existing unrelated lint warnings only) - `pnpm localization:check` - Regressions: `remote-login` (new admin-secret block: signed-in browser refused, loopback makes a readable secret, only the hash is saved, loose typing works, rotation kills the old secret, new secret works remotely, `.env` wins with 409, DELETE under `.env` clears the file), `access-policy`, `lockdown-setup-security`, `capability-internal-route`, `capability-package-lifecycle`, `docker-proxy-auth`, `loopback-proxy-auth-security`, `multiplayer-control-security`. Review: local CodeRabbit could not run (CLI not authenticated on this machine). A Marinara reviewer agent found nothing blocking; its 4 low/medium findings (Docker path, stale `.env`-only texts, old app secret reviving after `.env` removal, README) are fixed in the second commit. - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes Not done yet. Please verify: - On the server's own computer: **Settings → Advanced → Admin Access → Make admin secret** shows the secret once and fills the box; a privileged action (for example a backup) then works from a phone after typing the secret there. - **Replace admin secret** on a remote device that has the secret: the old secret stops working everywhere. - **Remove admin secret**: remote privileged actions fail again with the updated hint. - With `ADMIN_SECRET` in `.env`: Admin Access shows the `.env` note, no buttons. - Docker: host browser without a secret sees the `.env` pointer, not the buttons. - From a phone signed in with the login and **no** admin secret: opening an installed Home screen agent works; installing or removing an agent still asks for the secret. - Light/dark mode and 390 px width of the Admin Access section. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened Follow-up for translations: #8830 - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) No screenshots yet (see manual verification). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:40:03 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#8833
No description provided.