Skip to content

feat(auth): keep rotating sessions off the OS keychain - #647

Draft
adriannoes wants to merge 7 commits into
devfrom
fix/macos-encrypted-session-store
Draft

feat(auth): keep rotating sessions off the OS keychain#647
adriannoes wants to merge 7 commits into
devfrom
fix/macos-encrypted-session-store

Conversation

@adriannoes

Copy link
Copy Markdown
Collaborator

Summary

  • Opt-in PIPEFY_KEYCHAIN_BACKEND=encrypted stores the rotating OAuth session in AES-GCM session.enc with a create-once wrapping key (macOS Keychain / Windows DPAPI). Default auto still uses the OS keychain; Linux stays on Secret Service, file, or PIPEFY_TOKEN.
  • Uninstall scan/teardown now covers session.enc, wrapping.key, and the Darwin wrapping Keychain item so leftover encrypted-store artifacts are not stranded.
  • Review follow-up: recover unreadable session.enc on re-login without minting a wrapping key first; unique tmp + file lock for concurrent writers; persist wrapping keys before caching; Linux hints no longer advertise encrypted; MCP settings load lazily so --help is not blocked by invalid backend env; logout/docs name wrapping artifacts with the canonical service/account.

Test plan

  • uv run pytest packages/auth/tests -m "not integration" (219 passed)
  • CLI subset: packages/cli/tests/test_auth_keychain_hints.py, test_cli_settings.py, test_auth_login.py, test_auth_logout.py
  • uv run pytest tests/test_uninstall_scan.py tests/test_uninstall_teardown.py (118 passed)
  • uv run pytest packages/mcp/tests -m "not integration" (2027 passed)
  • uv run pytest -m "not integration"
  • uv run ruff check . && uv run ruff format --check .
  • Manual smoke (if applicable): pipefy auth login with PIPEFY_KEYCHAIN_BACKEND=encrypted on macOS; Linux encrypted rejected; ./uninstall.sh --scan reports wrapping artifacts

Docs / skills

  • docs/parity.md updated when MCP ↔ CLI coverage changed
  • Affected skills/ updated in this PR (or a paired PR)
  • No docs/skills update needed (auth/config/uninstall copy only; no MCP ↔ CLI coverage change)

Legal / contributions

  • Commits include DCO sign-off (git commit -s)
  • Regulated-domain skills include COMPLIANCE.md when applicable

Status

Draft: review-follow-up commits are on the branch; leave draft until a reviewer is ready to take it.

Opt-in AES-GCM session.enc with a create-once wrapping key so unsigned
Python processes stop re-prompting on refresh, and Windows avoids the
Credential Manager blob cap.

Signed-off-by: Adrianno Esnarriaga <esadrianno@gmail.com>
Prefer encrypted over Always Allow or plaintext file when macOS ACL
rewrites or WinError 1783 block the default OS store.

Signed-off-by: Adrianno Esnarriaga <esadrianno@gmail.com>
Scan and plan session.enc, wrapping.key, and the Darwin wrapping
Keychain item so teardown matches the new store.

Signed-off-by: Adrianno Esnarriaga <esadrianno@gmail.com>
Operators need the opt-in contract: auto still uses the OS keychain;
encrypted is macOS and Windows only.

Signed-off-by: Adrianno Esnarriaga <esadrianno@gmail.com>
Unreadable ciphertext blocked re-login, a shared tmp raced writers, and
Darwin/Windows could cache a wrapping key that never landed on disk.

Signed-off-by: Adrianno Esnarriaga <esadrianno@gmail.com>
Linux hints must not advertise an unsupported backend, and MCP --help
must not instantiate settings that reject PIPEFY_KEYCHAIN_BACKEND=encrypted.

Signed-off-by: Adrianno Esnarriaga <esadrianno@gmail.com>
Operators still saw OS-keychain-only copy, and scan/teardown must
identify the wrapping key with the canonical service and account.

Signed-off-by: Adrianno Esnarriaga <esadrianno@gmail.com>
@adriannoes adriannoes self-assigned this Aug 26, 2026
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