Repository navigation
Conversation
…erfinn#1449) Mode is hydrated synchronously, but Verbosity / API version only show the saved values after the async refreshConfigSchema call resolves with the advanced-state choices. Both tests waited for Mode and then asserted the dependent fields synchronously, so on a slow CI runner they could still see the placeholder ("verbosity▼"). Move those assertions into waitFor.
…nn#1451) * ✨ Feature(gui): configure server upload secret in settings PicGo Core already supports authenticating `POST /upload` with a shared secret (`Authorization: Bearer <secret>`, `X-PicGo-Secret` or `?secret=`), resolved from `PICGO_SERVER_SECRET` or `settings.server.secret`, but the GUI offered no way to set it. Add a masked secret field with a show/hide toggle to the PicGo Server dialog, next to host and port. The dialog saves the trimmed value as `settings.server.secret`; an empty value disables authentication. Saving already restarts the server, and Core reads the secret from config on `listen()`, so the main process needs no change and `PICGO_SERVER_SECRET` still takes precedence. The secret value is never added to the settings search index. * 🐛 Fix(gui): keep server secret when normalizing settings normalizeSettingsConfig only copied host, port and enable from `settings.server`, so after a reload the renderer state had no secret: the server dialog reopened with an empty secret field, and saving it again (e.g. after changing the port) would have silently cleared the secret and disabled authentication. Keep `secret` (falling back to an empty string) and cover it with a test. * 📝 Docs: document renderer config normalizer whitelist in AGENTS.md The server secret was dropped from renderer state because normalizeSettingsConfig only copies listed fields, and the server dialog re-saves the whole object. Record the rule for future changes: when adding a persisted config field, update the shared types, renderer state type, default value and normalizer, and add a round-trip normalizer test. Also give `settings.server.secret` an explicit empty default to follow that rule. * 📝 Docs: require English PRs and squash merges in AGENTS.md
|
please change the target branch to dev |
|
Thanks for the patch. Generating a secret does address the unauthenticated GUI server scenario, but I do not think we should automatically backfill one into existing configurations. That would break existing server integrations without an explicit user decision: requests that previously worked would begin returning 401 after an upgrade. As noted above, please target Please revise this toward an explicit GUI flow:
Please keep the renderer configuration synchronized after saving the secret, and include the new reminder preference in the shared types, defaults, and renderer normalizer so it survives a settings round trip. The current "leave empty to disable authentication" behavior should not silently turn into "generate a new secret" on restart. Tests should cover dismissal leaving the secret unchanged, persistence of the reminder preference, explicit generation and activation, preservation of existing secrets, and authenticated/unauthenticated requests after enabling authentication. Please also add localized dialog text and usage guidance. No Core behavior change is needed for this proposed GUI flow, since Core already provides the authentication mechanism. Users who decline authentication will still have the reported exposure, so the warning must clearly explain that tradeoff. |
Fixes #1454.
ensureConfig()currently creates the local upload server's first-run configuration with nosecret, and picgo-core treats a missing/empty secret as "authentication disabled" for every route including/upload. Combined with picgo-core's unrestricted CORS policy, this lets any web page the user visits make the server read an arbitrary local file and upload it through the user's configured image host, then read the resulting URL back cross-origin.This generates a random 24-byte secret on first run and backfills one into any pre-existing config that was saved without one. picgo-core already reads
settings.server.secretand enforces it on/uploadwhenever it is non-empty, so no change was needed outside this repo.Verified: a cross-origin request that previously returned
200with the exfiltrated file content now returns401 Unauthorizedonce the generated secret is in place, while a pre-existing config that already has a user-set secret is left untouched.