consul/agent/connect
Nitya Dhanushkodi 78b170ad50
xds controller: setup watches for and compute leaf cert references in ProxyStateTemplate, and wire up leaf cert manager dependency (#18756)
* Refactors the leafcert package to not have a dependency on agent/consul and agent/cache to avoid import cycles. This way the xds controller can just import the leafcert package to use the leafcert manager.

The leaf cert logic in the controller:
* Sets up watches for leaf certs that are referenced in the ProxyStateTemplate (which generates the leaf certs too).
* Gets the leaf cert from the leaf cert cache
* Stores the leaf cert in the ProxyState that's pushed to xds
* For the cert watches, this PR also uses a bimapper + a thin wrapper to map leaf cert events to related ProxyStateTemplates

Since bimapper uses a resource.Reference or resource.ID to map between two resource types, I've created an internal type for a leaf certificate to use for the resource.Reference, since it's not a v2 resource.
The wrapper allows mapping events to resources (as opposed to mapping resources to resources)

The controller tests:
Unit: Ensure that we resolve leaf cert references
Lifecycle: Ensure that when the CA is updated, the leaf cert is as well

Also adds a new spiffe id type, and adds workload identity and workload identity URI to leaf certs. This is so certs are generated with the new workload identity based SPIFFE id.

* Pulls out some leaf cert test helpers into a helpers file so it
can be used in the xds controller tests.
* Wires up leaf cert manager dependency
* Support getting token from proxytracker
* Add workload identity spiffe id type to the authorize and sign functions



---------

Co-authored-by: John Murret <john.murret@hashicorp.com>
2023-09-12 12:56:43 -07:00
..
ca [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
authz.go [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
authz_test.go [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
common_names.go [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
csr.go [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
csr_test.go [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
generate.go [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
generate_test.go [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
parsing.go [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
sni.go OSS -> CE (community edition) changes (#18517) 2023-08-22 09:46:03 -05:00
sni_test.go [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
testing_ca.go [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
testing_ca_test.go [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
testing_spiffe.go [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
uri.go xds controller: setup watches for and compute leaf cert references in ProxyStateTemplate, and wire up leaf cert manager dependency (#18756) 2023-09-12 12:56:43 -07:00
uri_agent.go [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
uri_agent_ce.go OSS -> CE (community edition) changes (#18517) 2023-08-22 09:46:03 -05:00
uri_agent_ce_test.go OSS -> CE (community edition) changes (#18517) 2023-08-22 09:46:03 -05:00
uri_mesh_gateway.go [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
uri_mesh_gateway_ce.go OSS -> CE (community edition) changes (#18517) 2023-08-22 09:46:03 -05:00
uri_mesh_gateway_ce_test.go OSS -> CE (community edition) changes (#18517) 2023-08-22 09:46:03 -05:00
uri_server.go [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
uri_service.go xds controller: setup watches for and compute leaf cert references in ProxyStateTemplate, and wire up leaf cert manager dependency (#18756) 2023-09-12 12:56:43 -07:00
uri_service_ce.go OSS -> CE (community edition) changes (#18517) 2023-08-22 09:46:03 -05:00
uri_service_ce_test.go OSS -> CE (community edition) changes (#18517) 2023-08-22 09:46:03 -05:00
uri_signing.go xds controller: setup watches for and compute leaf cert references in ProxyStateTemplate, and wire up leaf cert manager dependency (#18756) 2023-09-12 12:56:43 -07:00
uri_signing_test.go xds controller: setup watches for and compute leaf cert references in ProxyStateTemplate, and wire up leaf cert manager dependency (#18756) 2023-09-12 12:56:43 -07:00
uri_test.go xds controller: setup watches for and compute leaf cert references in ProxyStateTemplate, and wire up leaf cert manager dependency (#18756) 2023-09-12 12:56:43 -07:00
uri_workload_identity.go xds controller: setup watches for and compute leaf cert references in ProxyStateTemplate, and wire up leaf cert manager dependency (#18756) 2023-09-12 12:56:43 -07:00
uri_workload_identity_ce.go xds controller: setup watches for and compute leaf cert references in ProxyStateTemplate, and wire up leaf cert manager dependency (#18756) 2023-09-12 12:56:43 -07:00
uri_workload_identity_ce_test.go xds controller: setup watches for and compute leaf cert references in ProxyStateTemplate, and wire up leaf cert manager dependency (#18756) 2023-09-12 12:56:43 -07:00
x509_patch.go [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00
x509_patch_test.go [COMPLIANCE] License changes (#18443) 2023-08-11 09:12:13 -04:00