-
Notifications
You must be signed in to change notification settings - Fork 610
feat: vault as a service #4555
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
Merged
feat: vault as a service #4555
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
4328e15
chore: move apps to svc
chronark 39c519b
Merge branch 'main' of github.com:unkeyed/unkey into proto
chronark 0eaee6e
chore: move protos to reflect ownership
chronark 9dca886
feat: vault is its own service
chronark fe8d1eb
test: add vault tests
chronark 56c7811
Merge branch 'main' of github.com:unkeyed/unkey into vault
chronark 5be8ab1
Merge branch 'main' of github.com:unkeyed/unkey into vault
chronark 8ed95b0
Update cmd/vault/main.go
chronark 6d1fd9b
Merge branch 'main' of github.com:unkeyed/unkey into vault
chronark c32b23d
test: fuzz tests for vault
chronark 5cbc187
fix: env prefix
chronark e4551be
fix: liveness endpoints
chronark 9835182
fix: link cmd
chronark a84479e
fix: port
chronark 8ae8692
refactor: clean up decrypt validation
chronark 4b19b60
Merge branch 'main' into vault
chronark c375d14
fix: liveness
chronark d092a2d
Merge branch 'vault' of github.com:unkeyed/unkey into vault
chronark 6a1d745
Merge branch 'main' into vault
chronark 9434fb1
fmt: vet
chronark cd4eed3
revert: remote cache
chronark 61b251b
Update svc/vault/internal/storage/memory_test.go
chronark c79f8f5
Update web/apps/agent/services/vault/keyring/decode_and_decrypt_key.go
chronark 5a0cc20
Update svc/vault/internal/storage/memory_test.go
chronark 8ca0781
Merge branch 'main' of github.com:unkeyed/unkey into vault
chronark 3d806b6
fix: BUILD dep
chronark a688be2
fix: import correct package
chronark f20dd8f
Merge branch 'main' into vault
chronark dcdd1c6
chore: clean up
chronark 05cad93
Merge branch 'main' into vault
chronark 41fe545
Merge branch 'main' into vault
chronark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,4 @@ web | |
| proto | ||
| svc/ctrl/proto | ||
| svc/krane/proto | ||
| svc/vault/proto | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| # Generated by buf. DO NOT EDIT. | ||
| version: v2 | ||
| deps: | ||
| - name: buf.build/bufbuild/protovalidate | ||
| commit: 2a1774d888024a9b93ce7eb4b59f6a83 | ||
| digest: b5:6b7f9bc919b65e5b79d7b726ffc03d6f815a412d6b792970fa6f065cae162107bd0a9d47272c8ab1a2c9514e87b13d3fbf71df614374d62d2183afb64be2d30a | ||
| - name: buf.build/restatedev/sdk-go | ||
| commit: 9ea0b54286dd4f35b0cb96ecdf09b402 | ||
| digest: b5:822b9362e943c827c36e44b0db519542259439382f94817989349d0ee590617ba70e35975840c5d96ceff278254806435e7d570db81548f9703c00b01eec398e |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ go_library( | |
| "//cmd/krane", | ||
| "//cmd/preflight", | ||
| "//cmd/sentinel", | ||
| "//cmd/vault", | ||
| "//pkg/cli", | ||
| ], | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| load("@rules_go//go:def.bzl", "go_library") | ||
|
|
||
| go_library( | ||
| name = "vault", | ||
| srcs = ["main.go"], | ||
| importpath = "github.com/unkeyed/unkey/cmd/vault", | ||
| visibility = ["//visibility:public"], | ||
| deps = [ | ||
| "//pkg/cli", | ||
| "//pkg/uid", | ||
| "//svc/vault", | ||
| ], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| package vault | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/unkeyed/unkey/pkg/cli" | ||
| "github.com/unkeyed/unkey/pkg/uid" | ||
| "github.com/unkeyed/unkey/svc/vault" | ||
| ) | ||
|
|
||
| var Cmd = &cli.Command{ | ||
chronark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Version: "", | ||
| Commands: []*cli.Command{}, | ||
| Aliases: []string{}, | ||
| Description: "", | ||
| Name: "vault", | ||
| Usage: "Run unkey's encryption service", | ||
| Flags: []cli.Flag{ | ||
| // Server Configuration | ||
| cli.Int("http-port", "HTTP port for the control plane server to listen on. Default: 8080", | ||
| cli.Default(8060), cli.EnvVar("UNKEY_HTTP_PORT")), | ||
|
|
||
| // Instance Identification | ||
| cli.String("instance-id", "Unique identifier for this instance. Auto-generated if not provided.", | ||
| cli.Default(uid.New(uid.InstancePrefix, 4)), cli.EnvVar("UNKEY_INSTANCE_ID")), | ||
|
|
||
| cli.String("bearer-token", "Authentication token for API access.", | ||
| cli.Required(), | ||
| cli.EnvVar("UNKEY_BEARER_TOKEN")), | ||
|
|
||
| // Vault Configuration - General secrets (env vars, API keys) | ||
| cli.StringSlice("master-keys", "Vault master keys for encryption (general vault)", | ||
| cli.Required(), cli.EnvVar("UNKEY_MASTER_KEYS")), | ||
| cli.String("s3-url", "S3 endpoint URL for general vault", | ||
| cli.Required(), | ||
| cli.EnvVar("UNKEY_S3_URL")), | ||
| cli.String("s3-bucket", "S3 bucket for general vault (env vars, API keys)", | ||
| cli.Required(), | ||
| cli.EnvVar("UNKEY_S3_BUCKET")), | ||
| cli.String("s3-access-key-id", "S3 access key ID for general vault", | ||
| cli.Required(), | ||
| cli.EnvVar("UNKEY_S3_ACCESS_KEY_ID")), | ||
| cli.String("s3-access-key-secret", "S3 secret access key for general vault", | ||
| cli.Required(), | ||
| cli.EnvVar("UNKEY_S3_ACCESS_KEY_SECRET")), | ||
chronark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| Action: action, | ||
| } | ||
|
|
||
| func action(ctx context.Context, cmd *cli.Command) error { | ||
|
|
||
| config := vault.Config{ | ||
| // Basic configuration | ||
| HttpPort: cmd.RequireInt("http-port"), | ||
| InstanceID: cmd.RequireString("instance-id"), | ||
| S3Url: cmd.RequireString("s3-url"), | ||
| S3Bucket: cmd.RequireString("s3-bucket"), | ||
| S3AccessKeyID: cmd.RequireString("s3-access-key-id"), | ||
| S3AccessKeySecret: cmd.RequireString("s3-access-key-secret"), | ||
| MasterKeys: cmd.RequireStringSlice("master-keys"), | ||
| BearerToken: cmd.RequireString("bearer-token"), | ||
| } | ||
|
|
||
| err := config.Validate() | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| return vault.Run(ctx, config) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: vault | ||
| namespace: unkey | ||
| labels: | ||
| app: vault | ||
| component: unkey | ||
| spec: | ||
| replicas: 1 | ||
| selector: | ||
| matchLabels: | ||
| app: vault | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: vault | ||
| component: unkey | ||
| spec: | ||
| containers: | ||
| - name: vault | ||
| image: unkey/vault:latest | ||
| command: ["run", "vault"] | ||
| ports: | ||
| - name: http | ||
| containerPort: 8060 | ||
| protocol: TCP | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| env: | ||
| - name: UNKEY_HTTP_PORT | ||
| value: "8060" | ||
| - name: UNKEY_S3_URL | ||
| value: "http://s3:3902" | ||
| - name: UNKEY_S3_BUCKET | ||
| value: "vault" | ||
| - name: UNKEY_S3_ACCESS_KEY_ID | ||
| value: "minio_root_user" | ||
| - name: UNKEY_S3_ACCESS_KEY_SECRET | ||
| value: "minio_root_password" | ||
| - name: UNKEY_MASTER_KEYS | ||
| value: "Ch9rZWtfMmdqMFBJdVhac1NSa0ZhNE5mOWlLSnBHenFPENTt7an5MRogENt9Si6wms4pQ2XIvqNSIgNpaBenJmXgcInhu6Nfv2U=" | ||
| - name: UNKEY_BEARER_TOKEN | ||
| value: "vault-test-token-123" | ||
| livenessProbe: | ||
| httpGet: | ||
| path: /vault.v1.VaultService/Liveness | ||
| port: 8060 | ||
| initialDelaySeconds: 30 | ||
| periodSeconds: 10 | ||
| timeoutSeconds: 5 | ||
| failureThreshold: 3 | ||
| readinessProbe: | ||
| httpGet: | ||
| path: /vault.v1.VaultService/Liveness | ||
| port: 8060 | ||
| initialDelaySeconds: 5 | ||
| periodSeconds: 5 | ||
| timeoutSeconds: 3 | ||
| failureThreshold: 3 | ||
chronark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| resources: | ||
| requests: | ||
| memory: "64Mi" | ||
| cpu: "50m" | ||
| limits: | ||
| memory: "256Mi" | ||
| cpu: "200m" | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: vault | ||
| namespace: unkey | ||
| labels: | ||
| app: vault | ||
| component: unkey | ||
| spec: | ||
| type: ClusterIP | ||
| ports: | ||
| - name: http | ||
| port: 8060 | ||
| targetPort: 8060 | ||
| protocol: TCP | ||
| selector: | ||
| app: vault | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.