Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions internal/webserver/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,12 @@ func (n *kubeFilter) authorizationMiddleware(next http.Handler) http.Handler {
})
}

func (n *kubeFilter) handleRequest(request *http.Request, selector labels.Selector) {
func (n *kubeFilter) handleRequest(request *http.Request, selector labels.Selector, username string) {
// Requests handled with a selector are forwarded using the proxy ServiceAccount,
// so the Kubernetes audit event cannot retain the original user through
// impersonation. Record that identity before replacing the bearer token.
n.log.V(5).Info("proxying filtered request", "username", username, "method", request.Method, "uri", request.URL.Path)

req.SanitizeImpersonationHeaders(request)

selectorValue := selector.String()
Expand Down Expand Up @@ -649,7 +654,7 @@ func (n *kubeFilter) registerModules(ctx context.Context, root *mux.Router) {
// if there's no selector, let it pass to the
n.impersonateHandler(writer, request)
default:
n.handleRequest(request, selector)
n.handleRequest(request, selector, username)
}
})
}
Expand Down
Loading