Add support for k8s projected service account token for OAUTH (kafka) #3105
Labels
enhancement
kafka
Issues relating to kafka
needs investigation
It looks as though have all the information needed but investigation is required
Feature/Idea
Support file-based OIDC tokens that periodically get refreshed for OIDC-capable APIs (in my case, Kafka/Schema-registry) similar to how the kubernetes client works with projected volumes to mount service-account tokens.
Background
I am working with a 3rd party kafka provider and realized that I could use the projected service account token that EKS automatically mounts in a pod with a specified service account, which is a JWT managed by the AWS OIDC provider, to authenticate my services to the Kafka cluster. It seemed like a pretty great solution for short-lived auto-rotated auth tokens (yay security). I did have to create a small custom
AuthenticateCallbackHandler
(sry. Its Java.). But they added this OIDC support along with a FileTokenRetriever in the Kafka java client some time back. I modified it slightly to add a cache and re-read the file periodically, since the file get's refreshed.Implementation
File Cache resource
Initially, I saw that the Sarama Kafka component could use a cache resource to provide a token, so I tested out making a modified version (had to use Bento for the fork, for some reason dependencies were failing with connect on my machine) to try loading the token from a filepath in the pod (in my EKS case,
/var/run/secrets/eks.amazonaws.com/serviceaccount/token
). It worked great, but I then realized that the file cache doesn't have expiry or anything, and is described as mostly for debugging purposes.Dedicated mechanism
After trying that out, I thought maybe a better solution would be a more OIDC specific resource, that maybe had a better understanding of the refresh requirements or something. Maybe this wouldn't necessarily be a "component" per se, but a common set of functions that components could use to add a new form of auth if they wanted, e.g.:
Thoughts?
Anyway, I am not a whiz when it comes to oauth really. I'm a little new to it. However, when I figured out I could have a form of short-lived credentials, that my application didn't necessarily have to manage the rotation of, and getting all the benefits of a "workload identity" role, rather than doling out long-lived key/secrets for each service with different scopes, etc. I thought this was amazing and would be a great benefit for Benthos/Connect.
I don't think this would be very difficult to implement. And there is prior art in the form of the kubernetes client itself. Would this be something worth adding as an internal component?
Also, am I even thinking about this the right way? Again, I have little experience in OIDC, etc. I have used AWS IAM for a long time though, and want the same role-based workload identity. This seemed to work well, but I'm really not even sure it's the "correct" way to do things. I could only imagine the k8s api was pretty well vetted though. Anyway. Would love any feedback or linking in someone with good OIDC knowledge. For now I'll be plumbing in static vault secrets that aren't rotated regularly 😬
Links
The text was updated successfully, but these errors were encountered: