Skip to content

feat: Fix keychain issues and add fs fallback#10

Open
jpage-godaddy wants to merge 23 commits into
mainfrom
fix-keyring
Open

feat: Fix keychain issues and add fs fallback#10
jpage-godaddy wants to merge 23 commits into
mainfrom
fix-keyring

Conversation

@jpage-godaddy
Copy link
Copy Markdown
Collaborator

  • Add missing features for keyring to make it actually work instead of being a no-op (grr)
  • Allow option for storing token in a file as a fallback for keychain issues (disabled by default)
  • Add ability to get debug logging

- Add missing features for `keyring` to make it actually work instead of being a no-op (grr)
- Allow option for storing token in a file as a fallback for keychain issues (disabled by default)
- Add ability to get debug logging
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to make PKCE auth token persistence reliable by fixing keychain backend configuration and adding an opt-in file-based fallback for environments where the system keychain is unavailable, along with additional debug/warn logging around keychain operations.

Changes:

  • Add keyring OS-specific feature flags so keychain storage is functional on Linux/macOS/Windows.
  • Add an opt-in file fallback for token storage when keychain operations fail.
  • Add tracing logs around keychain read/write failures and fallback usage.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 6 comments.

File Description
src/auth/pkce.rs Implements file fallback storage/removal and adds keychain error logging.
Cargo.toml Configures keyring with OS-specific backend features.
Cargo.lock Updates lockfile for new/changed transitive dependencies pulled in by keyring features.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/auth/pkce.rs Outdated
Comment thread src/auth/pkce.rs Outdated
Comment thread src/auth/pkce.rs Outdated
Comment thread src/auth/pkce.rs Outdated
Comment thread src/auth/pkce.rs Outdated
Comment thread src/auth/pkce.rs
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 7 comments.

Comment thread src/auth/pkce.rs
Comment thread src/auth/pkce.rs
Comment thread src/auth/pkce.rs
Comment thread src/auth/pkce.rs
Comment thread src/auth/pkce.rs Outdated
Comment thread Cargo.toml Outdated
Comment thread Cargo.toml Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

Comment thread src/auth/pkce.rs Outdated
Comment thread src/auth/pkce.rs Outdated
Comment thread src/auth/pkce.rs
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

Comment thread src/auth/pkce.rs Outdated
Comment thread Cargo.toml
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.

Comment thread src/auth/pkce.rs Outdated
Comment thread src/auth/pkce.rs Outdated
Comment thread src/auth/pkce.rs Outdated
Comment thread src/auth/pkce.rs Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

Comment thread src/auth/pkce.rs
Comment thread src/auth/pkce.rs
Comment thread src/auth/pkce.rs Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

Comment thread src/auth/pkce.rs Outdated
Comment thread src/auth/pkce.rs Outdated
@jpage-godaddy jpage-godaddy requested a review from Copilot May 29, 2026 21:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

Comment thread src/auth/pkce.rs
Comment thread src/auth/pkce.rs Outdated
- config_base_dir: add .filter(|p| p.is_absolute()) so a relative
  XDG_CONFIG_HOME/APPDATA/HOME does not silently place credentials
  relative to the current working directory
- delete_token_from_keychain: handle JoinError with a WARN log,
  consistent with the read/write paths
- Add test: credential_file_path_rejects_relative_base_dir

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 6 comments.

Comment thread src/auth/pkce.rs
Comment thread src/auth/pkce.rs
Comment thread src/auth/pkce.rs
Comment thread src/auth/pkce.rs
Comment thread src/auth/pkce.rs
Comment thread src/auth/pkce.rs
- save_token_to_keychain: change "keychain is unavailable" to
  "failed to save token to keychain" so the message is accurate
  for all failure modes (permissions, locked, truly absent)
- Add file_fallback_round_trip_write_then_read: exercises
  write_token_file_blocking + load_token_from_file together
- Add file_fallback_invalid_json_returns_none: verifies corrupted
  credential files are handled gracefully

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

Comment thread src/auth/pkce.rs
Comment thread src/auth/pkce.rs
…ponents

is_safe_path_component now also rejects:
- trailing '.' or ' ' (valid on Unix but rejected by Windows)
- Windows reserved device names (CON, NUL, COM1-9, LPT1-9 with
  or without extension) — opening e.g. NUL.json on Windows writes
  to the null device rather than a file

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

Comment thread src/auth/pkce.rs
If std::fs::rename fails the token data would otherwise sit in an
orphaned *.tmp file. Now best-effort deletes the temp file before
returning the error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.

Comment thread src/auth/pkce.rs
Comment thread src/auth/pkce.rs Outdated
Comment thread src/auth/pkce.rs
Comment thread src/auth/pkce.rs Outdated
- save_token_to_keychain: when keychain write succeeds, best-effort
  delete any leftover file-fallback token (NotFound is silently
  ignored; other errors logged at debug)
- config_base_dir: update comment to accurately describe the non-Windows
  fallback order (HOME/.config first, then APPDATA as last resort)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

Comment thread src/auth/pkce.rs Outdated
Comment thread src/auth/pkce.rs
- delete_token_from_keychain: replace drop(delete_credential()) with
  a match that logs WARN on unexpected errors (NoEntry is silently
  ignored — token already gone is fine during logout)
- load_token_from_file: best-effort delete the file after logging
  invalid JSON so the system self-heals instead of forcing re-auth
  on every subsequent run

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

Comment thread src/auth/pkce.rs Outdated
Comment thread src/auth/pkce.rs
Comment thread .github/workflows/ci.yml
…, fix CI doc tests

- delete_token_from_keychain: clone service before closure so the
  JoinError warning includes the service name; log WARN when
  Entry::new fails (consistent with read/write helpers)
- load_token_from_keychain: best-effort delete the keychain entry
  when its JSON is corrupt, preventing repeated warnings on every run
- ci.yml: add --features pkce-auth to the Doc Tests step so the
  pkce module's no_run example is compile-checked in CI

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated no new comments.

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.

2 participants