Skip to content

Add support for a 1Password secrets provider #306

Closed

Description

@tomekchime

This is a feature request to add 1Password as a secrets-provider option. 1Password supports secret references which can be retrieved with the op CLI.

Activity

  1. JAORMX commented on Apr 30, 2025

    @JAORMX
    Collaborator

    Love it! This sounds like a great feature

  2. added
    enhancement
    p0
    on May 1, 2025
  3. ChrisJBurns commented on May 1, 2025

    @ChrisJBurns
    Collaborator

    Have added a draft PR (#316) to track this. Still digging into the details of what it would look like, but was easier than I thought it would be to get working (judging on the little time I spent on this)

  4. ChrisJBurns commented on May 2, 2025

    @ChrisJBurns
    Collaborator

    Ok, so I've done a bit more digging into the go-sdk.

    I much prefer it than executing the CLI from within ToolHive. The requirement for users that want to take advantage of the 1Password feature would have to have a service account created already that ToolHive to use (recommendation is probably to have a dedicated one for ToolHive to avoid sharing an existing token) that would be set via the OP_SERVICE_ACCOUNT_TOKEN environment variable and the token creation itself in 1Password is really quick and easy.

    I have pushed up the code in the above PR (#316) for a simple secret retrieval. It works really nicely, and doesn't even ask the user to login or authorise your terminal to access 1Password, so it makes it more seamless.

    The only slight issue is how the 1Password secrets are represented in our code and how it plays in with the Provider interface. Currently it looks like this:

    type Provider interface {
    	GetSecret(name string) (string, error)
    	SetSecret(name, value string) error
    	DeleteSecret(name string) error
    	ListSecrets() ([]string, error)
    	Cleanup() error
    }

    With the encrypted secrets type that already exists inside of ToolHive, the interface methods make sense because each secret is basically a key-value pairing. This makes it easy to get, set, delete and list. 1Password however, doesn't have the key-value structure. Instead, it follows the op://<vault-name>/<item-name>/[section-name/]<field-name> structure.

    This means getting/setting/deleting a secret would be done by path - not by name as the Provider method suggests. This is a trivial detail name/value, the larger issue is the ListSecrets endpoint. You wouldn't be listing the secrets, but instead you'd be listing the "Items" that exist in the vault. This would encompass "Passwords", "API Keys", you name it. This then makes the "Secret" nomenclature slightly misleading.

    The above is assuming that we'd want to allow for all of the methods to be implemented. If we at the moment are happy with users being able to Delete, Set and List secrets by going into 1Password directly and only allowing ToolHive to read them, then we can just make them noop methods.

    Welcome others thoughts

  5. ChrisJBurns commented on May 6, 2025

    @ChrisJBurns
    Collaborator

    This has been implemented in release 0.0.31

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementp0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions