-
Notifications
You must be signed in to change notification settings - Fork 1.6k
API server authentication to webhooks #658
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
Conversation
|
/sig api-machinery |
|
|
||
| ```go | ||
| type AuthInfo struct { | ||
| TokenRequest *authenticationv1.TokenRequestSpec |
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 not sure an entire token request spec makes sense, for a few reasons:
-
the target probably doesn't care about expiration or bound object, just audience
-
it seems safer to make the audience an inherent part of the way the webhook is called (e.g. tokens obtained for calling
https://mywebhook.comwould have an audience ofhttps://mywebhook.com, and tokens obtained for callingmyserviceinmynamespacewould have an audience ofhttps://myservice.mynamespace.svc, similar to how TLS validation for webhook calls is currently done)
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 was thinking the bound object would possibly be used to limit the exposure of a token, but probably isn't necessary
-
Being prescriptive with the audience makes sense.
So, from the API perspective, we probably just want a boolean switch. I'm thinking it still makes sense to wrap in an an AuthInfo struct so we can potentially add other methods down the road.
type AuthInfo struct {
ProvisionToken bool
}
type ClientConfig struct {
Name string
URL string
CABundle []byte
AuthInfo *AuthInfo
Service *ClientConfigService
}WDYT?
|
Trying to understand the proposal. Each call to a webhook would require the webhook to call back to the api server for a token validation? Would this be a significant overhad in a chain of validators? |
could you explain this a bit more? The general idea is to just provide a simple way to authenticate the apiserver, the immediate use case are the audit webhooks. These would only be a couple requests a minute. |
|
The connection between API Server and Webhooks are https. Currently Webhooks provide a CA in their config so API Server can authenticate them, we can do the reverse and API Servers can expose their CA so that the webhook can use it for https connection. I guess the problem need to be solved for that approach is multiple API Servers. But that can be fixed but the alternative suggestion of this KEP. They can be secret with ID of each API Server and we can provide the API Server's ID in |
|
👋 dropping in with two questions. Apologies if the answers are obvious, I'm just trying to understand the implications of the proposal.
|
@tsandall that's right. I think the missing features are
|
|
@caesarxuchao is there a reason that bearer tokens or client certificates could not be managed via an API like (or as part) webhook configurations? From my perspective, it's unclear why requiring webhook servers callback to the apiserver to authenticate (requests which the apiserver made) is desirable. Perhaps I'm misunderstanding the proposal. |
|
@tsandall related to your question one, I think the issue is you have to manage all the secrets in each api-server aggregated together into one config file passed through from the host into the kube-apiserver container. This is inconvenient. It would be nice if the secret could be stored as part of the dynamic registration process or if there was some other way to automatically managing the trust establishment. I think tokenreview is an api call back to the apiserver. So that means a validating web hook would go client -> apiserver -> validating webhook -> apiserver. which feels a bit heavy to me. What about a simpler option where a secret could be specified in the clientConfig section of the ValidatingWebhookConfiguration, and that secret is passed to the hook? the hook server could read the same secret and validate it was passed. Should be very easy to implement, should probably be good enough security, and not have the extra hop increasing performance? |
Agreed. Moving the "API" from a config file/command line argument into a first-class API seems natural.
Agreed.
I'm not sure what's best here. Embedding secrets inside the webhook configuration seems like it might be a problem? Alternatively, the webhook configuration could refer to a Secret? |
|
Yeah, thats what I was thinking. Just a reference to a secret (name, namespace, key) rather then the secret data itself. |
|
It is not universal yet I think, but you can get the ca out of the configmap cluster-info in the kube-public namespace. |
|
So @kfox1111 @tsandall we have definitely explored the secret route here but there were a couple issues we couldn't get past yet.
Check out Jordans talk from above #658 (comment) he does a good job at laying out the space. The solution presented is just intended to provide a simple means for cluster aware webhooks to authenticate. In our evaluation that was sufficient to solve the majority of use cases. We would like to solve the secret problem eventually but its looking like its going to be a complicated and sticky issue that may take awhile to resolve. |
|
/remove-lifecycle stale |
|
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
|
/remove-lifecycle stale |
|
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
|
/remove-lifecycle stale Per above comment, letting webhooks authenticate the API server would be very helpful for hardening K8s security model. |
|
|
||
| The `AuthInfo` struct will also be added to the [ClientConfig](https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/api/auditregistration/v1alpha1/types.go#L134) in the auditregistration API. | ||
|
|
||
| The token audience would be that of the webhook name. The receiving server could verify that it is the intended |
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.
For audience, please use the base address of the URL - not the webhook name. AFAIK this is the recommended use of audience.
| ``` | ||
|
|
||
| The client will check and refresh the token when necessary. The server can now check the token using a | ||
| [TokenReview](https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/authentication/types.go#L45). |
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.
Would be nice to also allow for the tokens to use proper OIDC, if the K8S server is integrated with such a IDP.
The audience-based tokens mounted in Pods seem to also support OIDC in some cases, would be great to be consistent.
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 agree with this suggestion.
This can also solve the case where the webhook/audit-endpoint is not kubernetes-aware. From a quick glance, this seems to be a problem that can eventually be solved by Istio and SPIFFE. I'm guessing the author is trying to provide a better user experience that can quickly establish auth with a simple flag/config.
|
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
|
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
|
/remove-lifecycle rotten Still interested in this |
|
I think the workflow can be broken down into two parts: 1) token issuing/ secret provisioning, and 2) token validation. Part 1 should be the core of this proposal. |
|
/cc |
|
should this be closed in favor of #2510? |
|
Closing in favor of #2510 |
|
@ritazh: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Adds proposal for outgoing webhook auth from the apiserver and its aggregates