-
Notifications
You must be signed in to change notification settings - Fork 5
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
Kubernetes Secrets Provider #2
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is seriously awesome to see. I'll leave approval to the other reviewers who can validate the K8s manifests more closely, and/or the Go code more closely, but from my perspective I just have questions & nits
secrets/secrets-kubernetes/main.go
Outdated
return nil, fmt.Errorf("%w: couldn't impersonate (%s)", secrets.ErrInvalidRequest, err.Error()) | ||
} | ||
|
||
kubeSecret, err := kubeClient.Secrets(policy.Namespace).Get(ctx, kubeSecretName, metav1.GetOptions{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3
if *secretsBackendSeed != "" { | ||
secretsBackendKey, err = nkeys.FromSeed([]byte(*secretsBackendSeed)) | ||
} else { | ||
slog.Info("Creating ephemeral curve keys. DO NOT USE THIS IN PRODUCTION.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually like the idea of using a completely ephemeral curve key, why wouldn't we want to do that given that the generated key shouldn't need to be used elsewhere?
Is the concern that, if you use an ephemeral key, that the host that's querying the backend may be unknowingly talking to a secrets backend that's malicious?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One downside to a just-in-time generated key as opposed to pre-generated key would be that you couldn't run multiple instances of the secret backend, because they would have different keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the concern that, if you use an ephemeral key, that the host that's querying the backend may be unknowingly talking to a secrets backend that's malicious?
precisely. as of now wasmcloudhost caches the backend server_xkey indefinitely, so we need to restart wasmcloudhost on secret backend key rotation.
the ⚖️ is that if we re-request server_xkey upon failure on the host, we might be talking to a rogue server. so maybe we need to look into verifying if a payload was signed with a known key ( signing keys style )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be fine as long as you don't want to run more than one instance of the secrets backend. If you did want to run more than one pod for the backend then you'd have an issue if each one has an ephemeral key, since each instance would have a different key, which means that hosts could have a chance of not being able to decrypt the response.
We talked about ways to mitigate this by having some sort of stateful API endpoint a host could to get a key and that backends would query to get their private key, but I think that may need to come in a later iteration of the secrets api.
|
||
func init() { | ||
SigningMethodEd25519 = &SigningMethodNats{} | ||
jwt.RegisterSigningMethod(SigningMethodEd25519.Alg(), func() jwt.SigningMethod { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm glad you can do this with Go packages, because I still have yet to find a Rust crate that will let you define arbitrary key signing methods
tested error serialization with host and it works now.
and also
|
Signed-off-by: Lucas Fontes <lucas@cosmonic.com>
d5cc050
to
13660cb
Compare
Kubernetes Secrets Backend Implementation for wasmCloud Secrets
Basic Usage
Get secret
app-secrets
in thedefault
namespace, and expose secret keysome-password
assome_password
to component.Advanced Usage ( Impersonation )
Get secret
cluster-secrets
in thekube-system
namespace, and expose secret keytls.crt
ascluster_certificate
to component.The backend will impersonate the
wasmcloud-secrets-privileged
ClusterRole, defined inimpersonate
.Machinery
server_xkey
andget
operations )Other backend providers can be implemented by using
secrets.NewServer()
and itssecrets.Handler
companion.