Repository navigation
fix: oidc auth - invalid bearer token, errorCause invalid bearer token (swall... - #4204
Conversation
Signed-off-by: Robert Markovski <5818108+Roshan931@users.noreply.github.com>
blacksoxx
left a comment
There was a problem hiding this comment.
Thanks for looking into this one, it has been a confusing error to debug. I traced the path on main and I think the reporter's expected line can be restored without a verbosity flag.
filters/authentication.go:75 (vendored k8s.io/apiserver) logs the error returned by the union authenticator, and the union authenticator aggregates the errors of each authenticator in the chain. Upstream's webhook token authenticator returns the review error when the token is not authenticated:
// vendor/k8s.io/apiserver/plugin/pkg/authenticator/token/webhook/webhook.go:170
if !r.Status.Authenticated {
var err error
if len(r.Status.Error) != 0 {
err = errors.New(r.Status.Error)
}
return nil, false, err
}vcluster's delegating authenticator returns nil, false, nil on the same branch, so the aggregate only ever contains invalid bearer token. Returning errors.New(tokReview.Status.Error) there mirrors upstream and brings back [invalid bearer token, oidc: email not verified] in the existing ERROR line, which is what #3930 asks for. A V(1) log works too but needs -v on the syncer; which of the two the maintainers prefer is their call, I just wanted to put the upstream behaviour next to it.
Two small things on the PR itself: the description mentions a unit test for the rejection path, but the diff only has the one file; and gofmt -l flags the file because the blank line between the import block and var ( was removed.

Fixes #3930
Root cause
vCluster proxy discards TokenReview status error
Changes
Note
Low Risk
Adds verbose logging on an existing rejection path; no change to authentication outcomes or error propagation.
Overview
When the vCluster proxy delegates bearer-token validation via
TokenReviewand the virtual cluster API server rejects the token, the delegating authenticator now emits a V(1) klog line includingtokReview.Status.Errorinstead of failing silently with no reason.Auth behavior is unchanged: rejected tokens still return unauthenticated with no error to the caller—only observability improves for debugging OIDC/invalid-token issues (e.g. #3930).
Reviewed by Cursor Bugbot for commit 129b251. Bugbot is set up for automated code reviews on this repo. Configure here.