Skip to content

fix: generate desktop auth secret per install - #71

Closed
hacksynth wants to merge 1 commit into
mainfrom
claude/issue-55-20260502-1648
Closed

hacksynth wants to merge 1 commit into
mainfrom
claude/issue-55-20260502-1648

Conversation

@hacksynth

Copy link
Copy Markdown
Owner

Closes #55

Summary

  • Remove hardcoded desktop auth secrets from .env.tauri.
  • Generate a per-install Base64 auth secret at runtime and inject AUTH_SECRET / NEXTAUTH_SECRET into the Tauri sidecar environment.
  • Write auth.secret atomically with owner-only creation semantics on Unix and document storage/loss behavior.

Review notes

Remove hardcoded NEXTAUTH_SECRET/AUTH_SECRET from .env.tauri and
generate a unique per-install secret at first sidecar startup.

- resolve_or_create_auth_secret(): reads auth.secret from Tauri app data
  dir; treats empty file as missing and regenerates (no empty-secret bug)
- create_secret_file(): uses create_new(true) + mode(0o600) at creation
  on Unix so permissions are set before any data is written; no
  write-then-chmod race
- write_secret_atomic(): removes any leftover .tmp file before calling
  create_new(true), then atomically renames temp -> final path
- Secret is 32 random bytes, Base64-encoded (44 chars via getrandom +
  base64 crates)
- AUTH_SECRET and NEXTAUTH_SECRET injected into sidecar process env
- docs/desktop-app.md: add Auth Secret section documenting per-platform
  storage paths, format, reuse across restarts, deletion impact, dev mode

Fixes #55

Co-authored-by: hacksynth <hacksynth@users.noreply.github.com>
@hacksynth

Copy link
Copy Markdown
Owner Author

Closing because Claude failed twice to push the remaining rustfmt-only fix, leaving this PR with a failing Tauri Check / rust status. The issue remains blocked on a manual cargo fmt --manifest-path src-tauri/Cargo.toml formatting update or a Claude environment that can apply/push the rustfmt line wraps. No code was changed manually per instruction.

@hacksynth hacksynth closed this May 2, 2026
@hacksynth
hacksynth deleted the claude/issue-55-20260502-1648 branch May 3, 2026 01:12
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.

.env.tauri hardcodes weak shared auth secrets

1 participant