Skip to content

✨ WIP KEP-6060: Webhook Auth integration - #3554

Open
benjaminapetersen wants to merge 6 commits into
kubernetes-sigs:mainfrom
benjaminapetersen:squad/kep-6060-integration
Open

✨ WIP KEP-6060: Webhook Auth integration#3554
benjaminapetersen wants to merge 6 commits into
kubernetes-sigs:mainfrom
benjaminapetersen:squad/kep-6060-integration

Conversation

@benjaminapetersen

Copy link
Copy Markdown

No description provided.

benjaminapetersen and others added 6 commits July 7, 2026 13:41
Implements the controller-runtime portion of KEP-6060 (API Server
Authentication to Admission Webhooks): an opt-in, webhook-side library
that verifies the bound, APIGroup-scoped service-account JWT presented
by kube-apiserver / aggregated API servers to admission webhooks.

Phase 1 (admission integration seam):
- Add admission.Authenticator interface and optional Webhook.Authenticator
  field, invoked in ServeHTTP after AdmissionReview decode and before the
  user handler. Nil authenticator preserves existing behavior exactly.
  Auth failures short-circuit and fail closed (401 unauthenticated /
  403 unauthorized).

Phase 2 (offline JWT verifier):
- Add pkg/webhook/admission/webhookauth: offline verification via
  go-jose/v4 with OIDC discovery + JWKS caching and fail-closed refresh,
  an explicit RS256 algorithm allow-list (rejects "none"/HS* per RFC 8725,
  audience-bound per RFC 9700), and issuer/exp/nbf/iat, binding, and
  allowedAPIGroup claim checks. No TokenReview round-trips (KEP mandate).
- Typed unauthenticated/unauthorized errors with no token material leakage.
- Adapter (NewAuthenticator) maps the Verifier onto admission.Authenticator.

Backward compatible: webhooks that do not adopt verification are
unaffected and silently ignore the Authorization header.

NOTE: upstream KEP-6060 wire format is not yet settled (k/k#140113 is WIP);
KEP-specific claim keys/field names are isolated as provisional constants
pending upstream api-review reconciliation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the controller-runtime-local JWT verifier with a thin adapter over the
k8s.io/webhook-auth library, so controller-runtime demonstrates a simple opt-in
to KEP-6060 API server authentication rather than duplicating verification logic.

pkg/webhook/admission/webhookauth is now a ~3-file adapter:
- NewAuthenticator(v *verify.Verifier) wraps the library verifier onto the
  admission.Authenticator seam, reusing controller-runtime's single
  AdmissionReview decode (admissionhttp.VerifyAdmissionReview) and the library's
  BearerToken helper. It fails closed and logs only verify.Reason(err).
- Deleted the local verifier / RemoteKeySet / OIDC re-implementation and its
  typed errors, dropping the direct github.com/go-jose/go-jose/v4 dependency.

The constructor intentionally takes a caller-built *verify.Verifier so no
JOSE/OIDC dependency enters controller-runtime. The library's zero-config
oidckeyset.NewInClusterVerifier is documented as a future optional helper
(pending SIG-Auth review) rather than wired here.

The Phase 1 admission.Authenticator seam (Webhook.Authenticator, invoked after
decode and before the handler) is unchanged; nil preserves existing behavior.

NOTE: depends on k8s.io/webhook-auth via a local replace; the module is not yet
published, so this branch is a preview pending upstream publication.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Benjamin A. Petersen <ben@benjaminapetersen.me>
…gthen tests

The k8s.io/webhook-auth library moved to a single-arg verify.NewVerifier(TokenAuthenticator) seam (iss/aud/exp now live in the authenticator; oidckeyset renamed to oidc). Update the adapter doc comments to the v2 surface (comments only, no behavior change) and rewrite the adapter tests to inject a fake verify.TokenAuthenticator instead of the removed v1 KeySet.

Tests: add mutating-bound and empty-bearer adapter cases; lock the core seam's denied-response default to 403 (was an uncovered fail-open branch). All pkg/webhook/admission tests green.
…webhookauth v3

Replace the pkg/webhook/admission/webhookauth/ subpackage adapter with a
native adapter in pkg/webhook/admission (verifierAuthenticator /
NewAuthenticator + fluent WithInClusterAuthenticator /
WithRemoteAuthenticator).

Migrate to the renamed no-dash k8s.io/webhookauth v3 API:
- Verify is now error-only
- admissionhttp.VerifyAdmissionRequest for admission-request verification
- incluster.InCluster for the in-cluster authenticator

The interim local `replace k8s.io/webhookauth => <local staging>` plus the
v0.0.0 pseudo-version is deliberate and load-bearing: the module is still
unpublished, so the local staging checkout is required to build.

Comprehensive authenticator_ext_test.go binding-violation coverage
(bothBound / noBound / mutatingApps) is deferred to a follow-up commit;
TODO markers are left in-file.

Signed-off-by: Benjamin A. Petersen <ben@benjaminapetersen.me>
…ticator

Restores the authenticator test coverage deferred from b027da3 (commit 1
left MINIMAL-compile TODO markers). Exercises controller-runtime's OWN adapter
fail-closed contract: verify-error deny (which at the CR layer subsumes the old
bothBound/noBound/mutatingApps binding violations), missing/malformed/empty/
wrong-scheme bearer token, nil verifier, and the 401 + HTTP-200 deny shape
through the ServeHTTP seam so a failurePolicy:Ignore webhook cannot flip a deny
into an admit. Also asserts no token material leaks into the deny response body.

The v3 exactly-one-of-(validating|mutating) webhook-binding checks moved INTO
k8s.io/webhookauth's authenticator; controller-runtime's offline verifier fake
cannot drive that internal binding logic, so those checks are covered by the
library's own test suite (documented via an in-file NOTE rather than a hollow
CR test).

Signed-off-by: Benjamin A. Petersen <ben@benjaminapetersen.me>
Surface the library verifier's HealthCheck() through Webhook.HealthCheck, a
healthz.Checker-compatible method (raw func(*http.Request) error, so the admission
package takes no healthz dependency). It is directly assignable to
mgr.AddReadyzCheck and safe to register unconditionally: when no verifier-backed
authenticator is configured it always reports ready.

When an in-cluster/remote authenticator is configured, readiness delegates to the
library verifier and reports not-ready until the audience is bound. This prevents a
pod that can never derive its audience from silently denying all traffic — it fails
readiness and is restarted instead.

Addresses McManus OBS-1 / cr-4 7.1.

Signed-off-by: Benjamin A. Petersen <ben@benjaminapetersen.me>
@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: benjaminapetersen
Once this PR has been reviewed and has the lgtm label, please assign alvaroaleman for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow

Copy link
Copy Markdown
Contributor

PR needs rebase.

Details

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-sigs/prow repository.

@kubernetes-prow kubernetes-prow Bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 17, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

@benjaminapetersen: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-controller-runtime-test 7968376 link true /test pull-controller-runtime-test
pull-controller-runtime-apidiff 7968376 link false /test pull-controller-runtime-apidiff

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

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-sigs/prow repository. I understand the commands that are listed here.

@kubernetes-prow kubernetes-prow Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 17, 2026
@benjaminapetersen

Copy link
Copy Markdown
Author

/hold

@kubernetes-prow kubernetes-prow Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 17, 2026
@benjaminapetersen

Copy link
Copy Markdown
Author

/sig auth
/kind feature
/status in-progress
/pony

@kubernetes-prow kubernetes-prow Bot added the sig/auth Categorizes an issue or PR as relevant to SIG Auth. label Jul 17, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

@benjaminapetersen: pony image

Details

In response to this:

/sig auth
/kind feature
/status in-progress
/pony

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-sigs/prow repository.

@kubernetes-prow kubernetes-prow Bot added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 17, 2026
@benjaminapetersen

Copy link
Copy Markdown
Author

/wip

@troy0820

Copy link
Copy Markdown
Member

/retitle ✨ WIP KEP-6060: Webhook Auth integration

Also, please disclose AI when submitting a pull-request
https://kubernetes.io/blog/2026/06/26/open-source-maintainership-in-the-age-of-ai/

@kubernetes-prow kubernetes-prow Bot changed the title KEP-6060: Webhook Auth integration ✨ WIP KEP-6060: Webhook Auth integration Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/feature Categorizes issue or PR as related to a new feature. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. sig/auth Categorizes an issue or PR as relevant to SIG Auth. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants