Skip to content

feat: Provision minimal TokenReview RBAC for OIDC auth and add SSL error logging in token parser#6240

Open
aniketpalu wants to merge 3 commits intofeast-dev:masterfrom
aniketpalu:oidc-rbac-ssl-logging
Open

feat: Provision minimal TokenReview RBAC for OIDC auth and add SSL error logging in token parser#6240
aniketpalu wants to merge 3 commits intofeast-dev:masterfrom
aniketpalu:oidc-rbac-ssl-logging

Conversation

@aniketpalu
Copy link
Copy Markdown
Contributor

@aniketpalu aniketpalu commented Apr 8, 2026

What this PR does / why we need it:

When `authz: oidc` is configured, the Feast server delegates Kubernetes service account (SA) tokens to a lightweight TokenReview for validation and namespace extraction. This requires the server SA to have `tokenreviews/create` permission. Previously, this RBAC was not provisioned automatically by the operator for OIDC deployments (only for `authz: kubernetes`), requiring manual ClusterRole creation.

Operator: OIDC TokenReview RBAC

The operator now provisions a dedicated feast-oidc-token-review ClusterRole and ClusterRoleBinding when authz: oidc is configured. The ClusterRole contains exactly one rule:

  • authentication.k8s.io/tokenreviews/create

This is the minimum permission needed for the SA token delegation path. No additional RBAC queries (rolebindings, clusterroles, namespaces) are granted, unlike the authz: kubernetes path which needs broader permissions for KubernetesTokenParser.

Cleanup is handled automatically when switching auth types:

  • OIDC to kubernetes: OIDC ClusterRole + ClusterRoleBinding deleted
  • OIDC to no_auth: OIDC ClusterRole + ClusterRoleBinding deleted
  • kubernetes/no_auth to OIDC: OIDC ClusterRole + ClusterRoleBinding created

SDK: SSL Error Logging

When verify_ssl: true is set but the OIDC provider uses self-signed certificates without a configured ca_cert_path, the server fails to reach the JWKS/discovery endpoints. Previously, this produced a generic "Invalid token" log with no indication of the root cause. The token parser now detects SSL errors in the exception chain and logs a clear, actionable message:

OIDC provider SSL certificate verification failed. If using a self-signed certificate,
set verify_ssl: false or provide a CA certificate via ca_cert_path.

This applies to both the discovery endpoint (_validate_token) and the JWKS endpoint (_decode_token) error paths.

Which issue(s) this PR fixes:

Follow up to #6089

Checks

  • I've made sure the tests are passing.
  • My commits are signed off (git commit -s)
  • My PR title follows conventional commits format

Testing Strategy

  • Unit tests
  • Integration tests
  • Manual tests
  • Testing is not required for this change

Misc


Open with Devin

…ror logging in token parser

Signed-off-by: Aniket Paluskar <apaluska@redhat.com>
@aniketpalu aniketpalu requested a review from a team as a code owner April 8, 2026 15:11
devin-ai-integration[bot]

This comment was marked as resolved.

Signed-off-by: Aniket Paluskar <apaluska@redhat.com>
Copy link
Copy Markdown
Collaborator

@jyejare jyejare left a comment

Choose a reason for hiding this comment

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

  1. The Kubernetes auth path sets a status condition (AuthorizationReadyType) to indicate RBAC provisioning success/failure. The OIDC path does not. This means operators have no visibility into whether the OIDC RBAC was actually created.

  2. The existing OIDC test (featurestore_controller_oidc_auth_test.go) verifies that the Kubernetes-auth Role/RoleBinding are absent, but it does not verify that the new feast-oidc-token-review ClusterRole and per-instance ClusterRoleBinding are created with the correct rules. It also doesn't test the cleanup path (switching from OIDC to no-auth should delete the CRB).

Comment on lines 400 to 402
func (authz *FeastAuthorization) getLabels() map[string]string {
return map[string]string{
services.NameLabelKey: authz.Handler.FeatureStore.Name,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

getLabels() stamps the FeatureStore-specific name. But the ClusterRole feast-oidc-token-review is shared across all OIDC FeatureStore instances. The last instance to reconcile overwrites the labels with its own name. This creates misleading audit trails — the ClusterRole appears to belong to one FeatureStore when it actually serves all of them.
Recommendation: Either use instance-independent labels for the shared ClusterRole, or use an aggregated label approach.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 7 additional findings in Devin Review.

Open in Devin Review

Comment on lines 30 to 39
if authz.isOidcAuth() {
if err := authz.createFeastClusterRole(); err != nil {
if err := authz.createOidcClusterRole(); err != nil {
return err
}
if err := authz.createFeastClusterRoleBinding(); err != nil {
if err := authz.createOidcClusterRoleBinding(); err != nil {
return err
}
} else {
authz.cleanupOidcRbac()
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 Orphaned Kubernetes auth ClusterRoleBinding when transitioning from Kubernetes auth to OIDC auth

Before this PR, the OIDC auth path in Deploy() called createFeastClusterRoleBinding(), which used the same CRB name as Kubernetes auth (GetFeastName(fs) + "-cluster-binding" at infra/feast-operator/internal/controller/authz/authz.go:444). Switching from Kubernetes to OIDC would therefore update the existing CRB in place via CreateOrUpdate. After this PR, the OIDC path creates a separate CRB with a different name (GetFeastName(fs) + "-oidc-token-review" at line 397). When transitioning from Kubernetes auth to OIDC, the old Kubernetes CRB (feast-{name}-cluster-binding) is never deleted — it has no owner reference (setFeastClusterRoleBinding at line 202 returns nil instead of calling SetControllerReference), so it won't be garbage collected either. The orphaned CRB continues to bind the service account to the broad Kubernetes auth ClusterRole (which grants access to subjectaccessreviews, rolebindings, namespaces, clusterroles, clusterrolebindings per lines 142-178), even though OIDC only needs tokenreviews:create. The PR correctly adds cleanupOidcRbac() for the OIDC→Kubernetes transition (line 21), but there is no symmetric cleanup of the Kubernetes CRB when transitioning away from Kubernetes auth.

Prompt for agents
In Deploy(), when the code enters the non-Kubernetes-auth branch (lines 25-41), it should also clean up the Kubernetes auth ClusterRoleBinding before proceeding with OIDC or no-auth setup. Add a cleanup step similar to cleanupOidcRbac() but targeting the Kubernetes auth CRB. For example, add a new method cleanupKubernetesClusterRbac() that deletes the ClusterRoleBinding named getFeastClusterRoleBindingName() (i.e. GetFeastName(fs) + "-cluster-binding"), and call it right after the existing namespace-scoped cleanup (after line 27, before the isOidcAuth check). This mirrors the pattern already established by cleanupOidcRbac() which is called in the Kubernetes auth path at line 21.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants