Skip to content

feat: enforce workload authorization and pod delete permissions on AuthProxyWorkload - #796

Open
hessjcg wants to merge 1 commit into
mainfrom
feat-workload-auth-validation
Open

hessjcg wants to merge 1 commit into
mainfrom
feat-workload-auth-validation

Conversation

@hessjcg

@hessjcg hessjcg commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR implements admission webhook authorization validation for AuthProxyWorkload resources. It addresses the security requirement ensuring that users creating or updating an AuthProxyWorkload resource possess sufficient RBAC permissions to modify the targeted workload and pods.

Changes

  1. SubjectAccessReview (SAR) Authorization Check in Validating Webhook:

    • Pod Delete Permission: Verifies the requester has delete verb on core/pods in the target namespace.
    • Workload Update/Patch Permission:
      • When a workload is referenced by name (spec.workload.name): checks update and patch permissions on that specific named resource (deployments, statefulsets, daemonsets, replicasets, jobs, cronjobs, or pods).
      • When a workload is selected by label selector (spec.workload.selector): checks namespace-wide update and patch permissions on the resource kind.
    • Container Override Permission: Verifies the user has create permission on the authproxyworkloads/containeroverride subresource when specifying custom authProxyContainer image/commands/args.
    • Metadata Update Optimization: Skips authorization check during ValidateUpdate if spec is unchanged (!reflect.DeepEqual(old.Spec, newObj.Spec)), allowing controller manager finalizer management without obstruction.
  2. RBAC & Controller Updates:

    • Added RBAC annotations for batch/jobs and batch/cronjobs (update, patch) to the operator ClusterRole.
    • Added RBAC annotation for authorization.k8s.io/subjectaccessreviews (create).
  3. Unit & E2E Tests:

    • Added comprehensive unit tests covering authorized and unauthorized scenarios across named resources, label selectors, container overrides, and spec updates.
    • Verified that all unit tests and GKE end-to-end integration tests (public & private clusters) pass cleanly.

@hessjcg hessjcg added the tests: run Run all the tests for this PR label Aug 24, 2026
…thProxyWorkload

Validates that users creating or updating an AuthProxyWorkload resource have
the necessary RBAC permissions on the targeted workload and pods:
- Requires 'delete' verb on pods in the namespace when creating/updating AuthProxyWorkload.
- Requires 'update' and 'patch' verbs on the specific workload resource (e.g. deployments, statefulsets, daemonsets, replicasets, jobs, cronjobs, or pods) when named or across the namespace when using label selectors.
- Requires 'authproxyworkloads/containeroverride' subresource permission when specifying custom container image/commands/args.
- Skips re-validation on metadata-only updates to permit controller finalizer management.
- Adds missing batch/jobs and batch/cronjobs update and patch permissions to the operator ClusterRole.
@hessjcg
hessjcg force-pushed the feat-workload-auth-validation branch from 935a527 to 0991664 Compare September 15, 2026 19:00
@hessjcg
hessjcg marked this pull request as ready for review September 15, 2026 19:06
@hessjcg
hessjcg requested a review from a team as a code owner September 15, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests: run Run all the tests for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant