Skip to content

feat: add sqlite credential store #853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

g-linville
Copy link
Member

@g-linville g-linville commented Sep 18, 2024

This adds a new credential store option, sqlite, which uses a pure Go SQLite driver with GORM to store credentials in a local SQLite database file.

By default, the SQLite file will be created at <xdg config dir>/gptscript/credentials.db, though this can be overridden with an environment variable. We also check for a Kubernetes EncryptionConfiguration file at <xdg config dir>/gptscript/encryptionconfig.yaml (this path can also be overridden with an environment variable). If this config file is present, we use it for configuration. We can do AES-GCM with a locally stored key, or something fancier like a KMS v2 plugin to support AWS KMS or some other third party service.

Here is an example encryptionconfig.yaml to use AES-GCM:

kind: EncryptionConfiguration
apiVersion: apiserver.config.k8s.io/v1
resources:
- resources:
  - credentials
  providers:
  - aesgcm:
      keys:
      - name: myKey
        secret: <encryption key encoded in base64>

For now I think we want to leave this undocumented? Let me know if I should remove the references to it in the error output (the output we display to the user when they configure an invalid credential store in their config file).

@@ -11,6 +11,7 @@ require (
github.com/docker/docker-credential-helpers v0.8.1
github.com/fatih/color v1.17.0
github.com/getkin/kin-openapi v0.124.0
github.com/glebarez/sqlite v1.11.0
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the pure Go SQLite driver for GORM.

Comment on lines +41 to +42
k8s.io/apimachinery v0.31.1
k8s.io/apiserver v0.31.1
Copy link
Member Author

Choose a reason for hiding this comment

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

I got approval from Darren to include whatever k8s dependencies were necessary to do encryption the same way we did it in mink.

Signed-off-by: Grant Linville <[email protected]>
@g-linville g-linville marked this pull request as ready for review September 18, 2024 20:37
@g-linville g-linville marked this pull request as draft September 18, 2024 20:48
@g-linville
Copy link
Member Author

Temporarily moved back to draft because I found a bug in my stacked credentials implementation. Working on it...

Signed-off-by: Grant Linville <[email protected]>
@g-linville g-linville marked this pull request as ready for review September 18, 2024 21:03
@g-linville
Copy link
Member Author

Should be good now.

Signed-off-by: Grant Linville <[email protected]>
@g-linville
Copy link
Member Author

Closing this since I am going to reimplement it as a separate application that we use as a credential helper.

@g-linville g-linville closed this Sep 19, 2024
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