Skip to content

Commit 6518075

Browse files
committed
Allow cluster admin revoke other intercepts
Signed-off-by: Phan Duc <phan.duc@moneyforward.co.jp>
1 parent aa632bf commit 6518075

File tree

5 files changed

+390
-256
lines changed

5 files changed

+390
-256
lines changed

CHANGELOG.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ items:
116116
The Traffic Agent's retry interval when it establishes its watcher for intercepts is now configurable using the Helm chart value
117117
`agent.watchRetryInterval`. The default retry interval was also increased from 2 seconds to 10 seconds to improve resilience when
118118
connections to the traffic manager are lost.
119+
- type: feature
120+
title: Add ability for cluster admins to revoke other users' intercepts.
121+
body: >-
122+
The Traffic Manager now has a new API endpoint `RevokeIntercept` that can be used to revoke intercepts created by other users.
123+
This endpoint is only accessible to cluster admins and requires authentication via a kubernetestoken and membership in the `system:masters` or `telepresence:admin` group.
119124
- version: 2.25.2
120125
date: 2025-12-26
121126
notes:

cmd/traffic/cmd/manager/service.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,31 @@ func (s *service) RemoveIntercept(ctx context.Context, riReq *rpc.RemoveIntercep
882882
return &empty.Empty{}, nil
883883
}
884884

885+
// RevokeIntercept allows the manager to revoke any client's intercept by intercept ID.
886+
// This is an administrative operation that can revoke intercepts for any client.
887+
func (s *service) RevokeIntercept(ctx context.Context, riReq *rpc.RevokeInterceptRequest) (*empty.Empty, error) {
888+
interceptID := riReq.InterceptId
889+
dlog.Debugf(ctx, "Revoking intercept ID %s", interceptID)
890+
891+
// Get the intercept to verify it exists and to update metrics
892+
intercept, ok := s.state.GetIntercept(interceptID)
893+
if !ok {
894+
return nil, status.Errorf(codes.NotFound, "Intercept with ID %q not found", interceptID)
895+
}
896+
897+
// Get the client session from the intercept to update metrics
898+
clientSessionID := tunnel.SessionID(intercept.ClientSession.SessionId)
899+
if client := s.state.GetClient(clientSessionID); client != nil {
900+
interceptName := intercept.Spec.Name
901+
SetGauge(ctx, s.state.GetInterceptActiveStatus(), client.Name, client.InstallId, &interceptName, 0)
902+
}
903+
904+
// Remove the intercept
905+
s.state.RemoveIntercept(ctx, interceptID)
906+
dlog.Infof(ctx, "Successfully revoked intercept ID %s", interceptID)
907+
return &empty.Empty{}, nil
908+
}
909+
885910
// GetIntercept gets an intercept info from intercept name.
886911
func (s *service) GetIntercept(ctx context.Context, request *rpc.GetInterceptRequest) (*rpc.InterceptInfo, error) {
887912
interceptID, err := s.MakeInterceptID(ctx, request.GetSession().GetSessionId(), request.GetName())

0 commit comments

Comments
 (0)