Skip to content

Conversation

@Zaggy21
Copy link
Contributor

@Zaggy21 Zaggy21 commented Dec 30, 2025

Description

This PR adds the Authorization Webhook in the authz chart and configures it in the local kind cluster setup. It uses NodePort service for the local setup. The authorizer is triggered after RBAC and only for greenhouse resources requests (see matchConditions in dev-env/webhook/structured-authz.yaml). Authorizer certificates generation is added into the setup-manager make target; mTLS is used for communication between kube-apiserver and authorization webhook.

What type of PR is this? (check all applicable)

  • 🍕 Feature
  • 🐛 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🤖 Build
  • 🔁 CI
  • 📦 Chore (Release)
  • ⏩ Revert

Related Tickets & Documents

Added tests?

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help
  • Separate ticket for tests # (issue/pr)

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Added to documentation?

  • 📜 README.md
  • 🤝 Documentation pages updated
  • 🙅 no documentation needed
  • (if applicable) generated OpenAPI docs for CRD changes

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

…ned-by label; add serviceaccount with rbac to authz

On-behalf-of: @SAP [email protected]
…olv.conf and use NodePort service with loopback IP instead

On-behalf-of: @SAP [email protected]
Comment on lines 47 to 50
scheme := runtime.NewScheme()
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(greenhousev1alpha1.AddToScheme(scheme))
utilruntime.Must(greenhousev1alpha2.AddToScheme(scheme))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can move this to init function and do it like this -

var (
	scheme   = runtime.NewScheme()
	setupLog = ctrl.Log.WithName("setup")
)

func init() {
	utilruntime.Must(clientgoscheme.AddToScheme(scheme))
    utilruntime.Must(greenhousev1alpha1.AddToScheme(scheme))
	utilruntime.Must(greenhousev1alpha2.AddToScheme(scheme))
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Done.

handleError(err, "Failed to create manager")

// Register the authorizer webhook.
dynClient, err := dynamic.NewForConfig(mgr.GetConfig())
Copy link
Contributor

@abhijith-darshan abhijith-darshan Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we not use mgr.GetClient() instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could use the typed client, but then I also need to use the meta.RESTMapper to get the Kind from the SubjectAccessReview, because it's not there by default. And we still need to operate on the Unstructured object, because it can be any of the Greenhouse CRDs.
gvr := schema.GroupVersionResource{ Group: attrs.Group, Version: attrs.Version, Resource: attrs.Resource, } gvk, err := mapper.KindFor(gvr) obj := &unstructured.Unstructured{} obj.SetGroupVersionKind(gvk) key := types.NamespacedName{Namespace: attrs.Namespace, Name: attrs.Name} client.Get(ctx, key, obj)
Is this solution better than the dynamic client?

@abhijith-darshan
Copy link
Contributor

abhijith-darshan commented Jan 6, 2026

e2e's are not working, was anything changed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] - PoC authorizer webhook for resource owners

3 participants