Skip to content

Add configurable SPIFFE ID template support - #269

Closed
akram wants to merge 1 commit into
rossoctl:mainfrom
akram:fix/268-configurable-spiffe-id-template
Closed

Add configurable SPIFFE ID template support#269
akram wants to merge 1 commit into
rossoctl:mainfrom
akram:fix/268-configurable-spiffe-id-template

Conversation

@akram

@akram akram commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #268

The client registration controller was hardcoding the SPIFFE ID format, but ClusterSPIFFEID resources allow custom spiffeIDTemplate configurations. This caused confusion when operator-generated Keycloak client IDs didn't match the actual SPIFFE IDs issued to workloads.

Changes

  • Add --spire-id-template flag with sensible default: spiffe://{{.TrustDomain}}/ns/{{.Namespace}}/sa/{{.ServiceAccount}}
  • Support SPIRE_ID_TEMPLATE environment variable for configuration (flag takes precedence)
  • Refactor resolveKeycloakClientID() to use text/template for rendering SPIFFE IDs
  • Add test coverage for custom template formats
  • Update documentation in operator-managed-client-registration.md

Template Variables

The template supports:

  • {{.TrustDomain}} - SPIRE trust domain
  • {{.Namespace}} - Kubernetes namespace
  • {{.ServiceAccount}} - Service account name

Configuration Precedence

  1. Command-line flag --spire-id-template (highest)
  2. Environment variable SPIRE_ID_TEMPLATE
  3. Default template (if neither is set)

Test plan

  • Unit tests pass (TestResolveKeycloakClientID)
  • Custom template rendering verified
  • Build succeeds after rebase onto latest main
  • Manual testing: Deploy with custom ClusterSPIFFEID template and verify client ID matches

🤖 Generated with Claude Code

@akram
akram requested a review from a team as a code owner April 10, 2026 10:27
@akram
akram force-pushed the fix/268-configurable-spiffe-id-template branch 3 times, most recently from 3e319bf to 020c4b4 Compare April 10, 2026 11:00
@grs

grs commented Apr 10, 2026

Copy link
Copy Markdown

This won't work as the ID need not be restricted to these three data items. If a different format is set, ot most likely will include some other element(s) (e.g. pod name, image etc).

…egistration controller

Fixes rossoctl#268

The client registration controller was hardcoding the SPIFFE ID format
as spiffe://{trustDomain}/ns/{namespace}/sa/{serviceAccount}, but SPIRE's
ClusterSPIFFEID resources allow custom spiffeIDTemplate configurations.
This caused confusion when the operator-generated client IDs didn't match
the actual SPIFFE IDs issued to workloads.
Add comprehensive end-to-end tests for the ClientRegistration controller
that verify OAuth client registration in Keycloak and Secret management.

Changes:
- Add --spire-id-template flag (default: spiffe://{{.TrustDomain}}/ns/{{.Namespace}}/sa/{{.ServiceAccount}})
- Support SPIRE_ID_TEMPLATE environment variable for configuration
- Refactor resolveKeycloakClientID to use text/template for rendering
- Update tests to verify template rendering with custom formats
- Document the new flag and environment variable in operator docs
- Mock Keycloak server that simulates admin API for client registration
- authbridge-config and keycloak-admin-secret ConfigMaps/Secrets
- Agent Deployments for testing non-SPIRE and SPIRE modes

The template supports variables: {{.TrustDomain}}, {{.Namespace}}, {{.ServiceAccount}}
Command-line flag takes precedence over environment variable.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Akram <akram.benaissi@gmail.com>
@akram
akram force-pushed the fix/268-configurable-spiffe-id-template branch from 020c4b4 to c35437f Compare April 10, 2026 15:16
@akram

akram commented Apr 10, 2026

Copy link
Copy Markdown
Contributor Author

per discussion, it seems indeed that this would be insufficient way of solving the issue. closing

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.

🐛 Client registration controller assumes default format for SPIFFE IDs

2 participants