Skip to content

[FEATURE]: Allow storage of secrets in system credential store. #4318

Closed

Description

@monostop

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Hi,

OpenCode currently stores auth tokens in a plaintext file (~/.local/share/opencode/auth.json). This works, but in my corporate environment we’re not allowed to keep access tokens unencrypted on disk, so I can’t use OpenCode. Would it be possible to add support for storing api keys in the system keyring instead?

Proposed approach:

Add opt-in keyring support using the @napi-rs/keyring library or Bun.secrets, which provides cross-platform access to system credential stores (GNOME Keyring/libsecret on Linux, Keychain on macOS, Credential Manager on Windows).

Implementation details:

  • Opt-in only: Add a --keyring flag to opencode auth login that enables keyring mode. Default behavior remains unchanged.
  • Config persistence: Once enabled, the setting persists in ~/.config/opencode/config.json so subsequent auth operations automatically use the keyring.
  • Storage format: Store credentials in the system keyring with service name opencode, account name as the provider ID (e.g., anthropic, github-copilot), and the credential object as JSON.

Related issues:

#1703 - An implementation using Bun.secrets.
#2405 - Command-based API key loading (alternative approach using secret manager CLIs)

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Nov 14, 2025
  2. rekram1-node commented on Nov 14, 2025

    @rekram1-node
    Collaborator

    Yeah I think using Bun secrets would be rlly good

  3. monostop commented on Nov 14, 2025

    @monostop
    ContributorAuthor

    I'll start on an implementation using Bun secrets. @rekram1-node, do you think it makes sense to keep old behavior (plain-text json file) as the default behavior for now and only enable the secrets implementation using the --keyring flag on the auth login command?

  4. rekram1-node commented on Nov 14, 2025

    @rekram1-node
    Collaborator

    Yeah I think keeping both behaviors makes sense, I think there are some environments that the auth json would be better for (could be wrong would have to read the bun secrets stuff for to be sure)

    I do think a flag is good but it also seems like a setting someone would always want on so maybe an option in their opencode config or something would be good too

  5. bogorad commented on Nov 14, 2025

    @bogorad

    Personally, I built this tiny win11-utility that translates calls to /run/secrets to sops decrypt that uses a key derived from my ssh key for decryption, so I can use {file:/run/secrets/api_keys/whatever} both for linux and windows :)

    https://github.com/bogorad/win-secrets

  6. monostop commented on Nov 17, 2025

    @monostop
    ContributorAuthor

    I hit a few teething issues with Bun.secrets in my initial attempt (details here: oven-sh/bun#24711). I’ll take a closer look later this week. I do have a workaround using @napi-rs/keyring, but using Bun natively would make far more sense if I can get it working.

  7. monostop commented on Dec 1, 2025

    @monostop
    ContributorAuthor

    The Bun maintainers have fixed the issue and it now the implementation with Bun.secrets works in the bun canary release. I'll continue with the development and create the PR when the fix is in the bun repo is officially released.

  8. rekram1-node commented on Dec 2, 2025

    @rekram1-node
    Collaborator

    nice!

  9. Brooooooklyn commented on Feb 20, 2026

    @Brooooooklyn
  10. github-actions commented on Apr 22, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  11. theRoboxx commented on Jun 25, 2026

    @theRoboxx

    I think this would be an essential enhancement to the tool. Any updates on it?

  12. tkoop commented on Sep 26, 2026

    @tkoop

    This is a good idea. We should do this. I would up-vote this if I could.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions