Skip to content

Secure Puter session storage and verify login on app startup - #6

Draft
CodeByArnob wants to merge 7 commits into
mainfrom
feat/secure-puter-session-storage
Draft

CodeByArnob wants to merge 7 commits into
mainfrom
feat/secure-puter-session-storage

Conversation

@CodeByArnob

Copy link
Copy Markdown
Owner

Summary

This draft implements the safe credential-storage and startup-validation foundations for the external-browser authentication work.

Changes

  • Add flutter_secure_storage 11.2.0, using Android Keystore-backed encrypted storage (RSA-OAEP + AES-GCM defaults).
  • Migrate the existing Puter token from SharedPreferences to secure storage. The old preference key is removed only after a secure write and read-back verification succeeds.
  • Keep a process-memory cache so existing synchronous token reads remain compatible; the token is not persisted in plaintext preferences after migration.
  • Disable Android Auto Backup so encrypted secure-storage data is not restored without its Keystore key.
  • Stop injecting a cached token into the WebView before server-side validation.
  • Verify saved credentials against Puter's /whoami endpoint before restoring the authenticated UI state.
  • Clear stored credentials and cached identity on explicit 401/403 invalid-session responses.
  • Treat network/server errors separately: keep the encrypted credential for retry, but do not show the cached user as authenticated.
  • Remove the permissive token-validation fallback that previously accepted unverified token strings and could synthesize a local user.

Not included / blocking requirement

This PR does not claim to implement Chrome-to-app session handoff. The documented Puter.js flow returns a browser-side popup result; no official native Android redirect/PKCE callback contract has been verified. A secure handoff still requires a supported Puter native callback or a reviewed one-time relay design. No bearer token is placed in a URL, no Chrome cookies/storage are scraped, and no unverified deep-link token is accepted.

Validation

CI must install the new dependency and run format, analyze, tests, and Android build. Physical-device validation is still required for KeyStore migration and startup verification.

Closes neither the external-browser handoff nor issue #1 until that final part is implemented and tested.

This branch has not been deployed

No deployments
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