-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Reissue kube certs when assuming access request #50553
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
Changes from all commits
30f5d49
2bad500
3b514a8
ad44239
341eac2
b635feb
513db25
9fdbf3d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -811,6 +811,28 @@ func (s *Service) AssumeRole(ctx context.Context, req *api.AssumeRoleRequest) er | |
| return trace.Wrap(err) | ||
| } | ||
|
|
||
| // Clear certs in kube gateways. | ||
| // Access requests may grant elevated permissions for accessing a kube cluster. | ||
| // To allow the user to use these permissions, we clear the existing certs. | ||
| // When a kube proxy receives a new request, it will issue new certs, | ||
| // similarly to the process when certs expire. | ||
| // | ||
| // We don't know which gateways are affected by the access request, | ||
| // so we need to clear certs for all of them. | ||
| s.mu.RLock() | ||
| defer s.mu.RUnlock() | ||
| for _, gw := range s.gateways { | ||
|
gzdunek marked this conversation as resolved.
|
||
| targetURI := gw.TargetURI() | ||
| if !(targetURI.IsKube() && targetURI.GetRootClusterURI() == cluster.URI) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this correct? a gateway from a leaf cluster can be modified when you assume a root cluster role
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think so. As Grzegorz wrote in the PR description:
If you assume a root cluster role, AFAIK we cannot easily tell if it affects leaf cluster resources.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, Rafał's explanation is correct. |
||
| continue | ||
| } | ||
| kubeGw, err := gateway.AsKube(gw) | ||
| if err != nil { | ||
| s.cfg.Logger.ErrorContext(ctx, "Could not clear certs for kube when assuming request", "error", err, "target_uri", targetURI) | ||
| } | ||
| kubeGw.ClearCerts() | ||
| } | ||
|
|
||
| // We have to reconnect using the updated cert. | ||
| return trace.Wrap(s.ClearCachedClientsForRoot(cluster.URI)) | ||
| } | ||
|
|
||
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.
should we care about the teleport cluster?
It's possible you have the same cluster name in two different teleport clusters
Uh oh!
There was an error while loading. Please reload this page.
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 reading the teleport cluster using
TeleportClusterFromKubeLocalProxySNI()before reading the kube cluster.Then
m.certReissuer()is called with that pair of teleport + kube cluster.Do you mean something else?