Skip to content

[Feature]: Store Credentials in System Keyrings with JSON Fallback #2639

@laraibg786

Description

@laraibg786

Problem Description

Currently, Context7 stores authentication credentials in a plaintext JSON file (~/.context7/credentials.json or following XDG standards ~/.config/context7/credentials.json). This approach has several drawbacks:

  1. Security Risk: Credentials are stored in plaintext on disk, making them vulnerable if:
    • The home directory is compromised
    • Backups are not encrypted
    • The machine is shared or accessed by other users
    • The disk is physically stolen
  2. Non-Standard Practice: Modern CLI tools (AWS CLI, GitHub CLI, gcloud, etc.) use system credential storage instead of plaintext JSON files
  3. Compliance Issues: Many organizations require credentials to be stored in secure vaults rather than plaintext

Proposed Solution

Implement a multi-backend credential storage system that:

  1. Prioritizes System Keyrings (in order of availability):
    • Linux: libsecret (GNOME Keyring, KDE Wallet)
    • macOS: Keychain
    • Windows: Credential Manager
  2. Fallback to JSON: Only use JSON file storage when no system keyring is available (e.g., headless servers, minimal environments)
  3. Smart Migration: On first run, detect which backend is available and optionally migrate existing JSON credentials
  4. On rollout, try to migrate the existing credentials.json to keyring if available when ran.

Alternatives Considered

No response

Priority

Would improve my workflow

Additional Context

These tools successfully implemented keyring support:

  1. GitHub CLI (gh):
  2. AWS CLI v2:
    • Stores temporary credentials in keyring when available
    • Falls back to ~/.aws/credentials on unsupported systems
    • User can configure preference via config file
  3. GitLab CLI (glab):
  4. gcloud CLI:
    • Stores authentication tokens in keyring
    • Graceful fallback for headless environments

npm/Node.js:

  • npm uses keytar for storing auth tokens
  • Popular in Node.js ecosystem

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions