Skip to content

Use SPIFFE identity instead of client secret - #916

Closed
Alan-Cha wants to merge 8 commits into
rossoctl:mainfrom
Alan-Cha:spiffe-keyclaok2_demo
Closed

Alan-Cha wants to merge 8 commits into
rossoctl:mainfrom
Alan-Cha:spiffe-keyclaok2_demo

Conversation

@Alan-Cha

Copy link
Copy Markdown
Member

Replace #769

Comment on lines -58 to +62
image: quay.io/keycloak/keycloak:26.3.3
image: quay.io/keycloak/keycloak:26.5.2
args: ["start"]
env:
- name: KC_FEATURES
value: "client-auth-federated:v1,spiffe:v1"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Update Keycloak and enable features for federated auth


v1 = client.CoreV1Api()

logger.info(f"Reading credentials from Secret: {KEYCLOAK_NAMESPACE}/{KEYCLOAK_ADMIN_SECRET_NAME}")

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This expression logs
sensitive data (secret)
as clear text.

except ApiException as e:
logger.error(f"❌ Failed to read Secret: {e}")
logger.error(f"Ensure Secret exists: kubectl get secret -n {KEYCLOAK_NAMESPACE} {KEYCLOAK_ADMIN_SECRET_NAME}")

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This expression logs
sensitive data (secret)
as clear text.
Comment thread charts/kagenti-deps/values.yaml Resolved
Comment on lines +227 to +244
apiVersion: v1
kind: ConfigMap
metadata:
name: kagenti-webhook-config
namespace: {{ . }}
labels:
{{- include "kagenti.labels" $root | nindent 4 }}
data:
SPIRE_ENABLED: "{{ $root.Values.spire.enabled }}"
KEYCLOAK_URL: "{{ $root.Values.keycloak.url }}"
KEYCLOAK_REALM: "{{ $root.Values.keycloak.realm }}"
KEYCLOAK_NAMESPACE: "{{ $root.Values.keycloak.namespace }}"
KEYCLOAK_ADMIN_SECRET_NAME: "{{ $root.Values.keycloak.adminSecretName }}"
KEYCLOAK_ADMIN_USERNAME_KEY: "{{ $root.Values.keycloak.adminUsernameKey }}"
KEYCLOAK_ADMIN_PASSWORD_KEY: "{{ $root.Values.keycloak.adminPasswordKey }}"
CLIENT_AUTH_TYPE: "{{ $root.Values.authBridge.clientAuthType }}"
SPIFFE_IDP_ALIAS: "{{ $root.Values.authBridge.spiffeIdpAlias }}"
JWT_AUDIENCE: "{{ $root.Values.keycloak.publicUrl }}/realms/{{ $root.Values.keycloak.realm }}"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Configmap that stores various data for client auth in each agent namespace, which now also requires various new fields for federated auth.

This didn't exist before? This confuses me. How does AuthBridge work without this configmap being automatically created? For the GitHub demo, we do the following:

https://github.com/kagenti/kagenti-extensions/blob/main/AuthBridge/demos/github-issue/k8s/configmaps.yaml

The old config doesn't have admin credentials. How is client auth getting these credentials then? It's getting the credentials from a secret?

TODO: Remove client admins from here

apiVersion: v1
kind: ConfigMap
metadata:
name: kagenti-webhook-config

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I thought the metadata used to be environments? Did I rename it to kagenti-webhook-config? What is authbridge-config from https://github.com/kagenti/kagenti-extensions/blob/main/AuthBridge/demos/github-issue/k8s/configmaps.yaml

jwt_svids = [{jwt_audience="kagenti", jwt_svid_file_name="/opt/jwt_svid.token"}]
# jwt_audience MUST match Keycloak's issuer URL exactly (use publicUrl, not internal url)
# The JWT-SVID's aud claim must match the "iss" claim in tokens issued by Keycloak
jwt_svids = [{jwt_audience="{{ $root.Values.keycloak.publicUrl }}/realms/{{ $root.Values.keycloak.realm }}", jwt_svid_file_name="/opt/jwt_svid.token"}]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The jwt_audience really matters now. It used to be an invalid value kagenti. If the jwt_audience doesn't match, federated auth will fail

Comment on lines +159 to +163
# CLIENT_AUTH_TYPE: Controls how Keycloak clients authenticate
# - "client-secret": Traditional client_secret authentication (default)
# - "federated-jwt": JWT-SVID authentication via SPIFFE identity provider
# For federated-jwt, you must configure a SPIFFE identity provider in Keycloak
clientAuthType: "client-secret"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

What should the default clientAuthType be? Right now it's set to client-secret. I think this makes sense for now but how do we transition to federated-jwt?

Comment thread charts/kagenti/values.yaml Resolved
Comment on lines +1012 to +1048
- name: Create RoleBinding for SPIFFE IdP setup (Keycloak secrets)
kubernetes.core.k8s:
state: present
definition:
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: kagenti-spiffe-idp-keycloak-reader
namespace: "{{ kagenti_deps_values.keycloak.namespace }}"
labels:
app.kubernetes.io/managed-by: ansible
app.kubernetes.io/part-of: kagenti
subjects:
- kind: ServiceAccount
name: kagenti-spiffe-idp-setup
namespace: "{{ (charts['kagenti-deps'] | default({})).get('namespace', 'kagenti-system') }}"
roleRef:
kind: ClusterRole
name: kagenti-spiffe-idp-reader
apiGroup: rbac.authorization.k8s.io

- name: Create Role for SPIFFE IdP setup (SPIRE pod reading)
kubernetes.core.k8s:
state: present
definition:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: kagenti-spiffe-idp-pod-reader
namespace: "{{ charts.spire.server_namespace }}"
labels:
app.kubernetes.io/managed-by: ansible
app.kubernetes.io/part-of: kagenti
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Requires creating roles for checking the status of SPIFFE components and roles for reading Keycloak admin credential secrets

Comment on lines +358 to +359
logger.info(f"1. Set authBridge.clientAuthType: 'federated-jwt' in values.yaml")
logger.info(f"2. Deploy agents - they will automatically use JWT-SVID authentication")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These logs don't make any sense because nobody will see them and follow these instructions unless they're debugging.

Comment thread deployments/ansible/default_values.yaml Outdated
enabled: false
namespace: spire-mgmt
namespace: spire-mgmt # Helm release namespace
server_namespace: spire-server # Actual SPIRE server component namespace

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The SPIRE namespace seems to be all over the place.

Should it be spire-server or should it be zero-trust-workload-identity-manager?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Some context from Claude:

The namespace name comes from Red Hat OpenShift's ZTWIM (Zero Trust Workload Identity Manager) operator.

Key Historical Context:
October 2025 - Commit a314dd8 "split main kagenti chart in dependencies and kagenti chart"

Introduced spire.namespace: zero-trust-workload-identity-manager in kagenti-deps/values.yaml:160
November 2025 - Commit e9ddb67 "update kagenti chart to support ZTWIM operator in OCP"

Added support for OpenShift's ZTWIM operator which provides managed SPIRE installation
The operator is called openshift-zero-trust-workload-identity-manager
February 2026 - Commit d49ccd4 "Remove spire namespace to simply Tornjak support"

Removed namespace creation from kagenti-deps chart
The namespace is now owned and created by either:
OpenShift (OCP 4.19+): ZTWIM operator installs into zero-trust-workload-identity-manager
Kubernetes/older OpenShift: Upstream SPIRE Helm chart creates the namespace
Why This Namespace Name?
The namespace zero-trust-workload-identity-manager matches the OpenShift operator name openshift-zero-trust-workload-identity-manager. OpenShift's ZTWIM operator is Red Hat's enterprise-supported distribution of SPIRE for OpenShift 4.19+.

For consistency across OpenShift and Kubernetes deployments, the Kagenti team chose to use the same namespace name (zero-trust-workload-identity-manager) for both platforms, even though:

On Kubernetes: The upstream SPIRE Helm chart traditionally uses spire-server
On OpenShift 4.19+: The ZTWIM operator enforces zero-trust-workload-identity-manager
This ensures the same values files work for both platforms without namespace mismatches.

agenti-webhook-config with environments configmap

Signed-off-by: Alan Cha <[email protected]>
@@ -0,0 +1,122 @@
# SPIFFE Identity Provider Setup

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

TODO: Was this added accidentally?

@esnible esnible changed the title Use SPIFFE identity instead of client secret#769 Use SPIFFE identity instead of client secret Mar 12, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. If this PR is still relevant, please comment or remove the stale label.

@github-actions github-actions Bot added the stale label May 12, 2026
@github-actions

Copy link
Copy Markdown

This pull request was closed because it has been stale for 14 days with no activity. Feel free to reopen if this is still relevant.

@github-actions github-actions Bot closed this May 26, 2026
@github-project-automation github-project-automation Bot moved this from New /:ToDo to Done in Rossoctl Issue Prioritization May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants