fix(ecr): serve the registry data plane over TLS (#4040)

- Update ECR host routing regex to support <account>.dkr.ecr.<region>.localhost.floci.io
- Populate regional wildcard SANs (*.dkr.ecr.<region>.localhost.floci.io) for all advertised AWS regions
- Add unit tests for hostname matching, malformed host rejection, immutable tag mutability over TLS, and certificate SAN enumeration
- Add Docker integration test verifying end-to-end TLS image push/pull with root CA verification and plain HTTP regression
- Update ECR and TLS user documentation
This commit is contained in:
Simone Primarosa authored and GitHub committed 2026-09-20 22:11:46 -04:00
1 parent 9dab36197a
commit 7777a97de9
7 files changed
+454 -12

No files matched your search

@@ -1,6 +1,7 @@
package io.github.hectorvent.floci.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.core.common.AwsRegions;
import io.github.hectorvent.floci.services.acm.CertificateGenerator;
import io.github.hectorvent.floci.services.acm.model.KeyAlgorithm;
import org.eclipse.microprofile.config.spi.ConfigSource;
@@ -64,13 +65,21 @@ public class TlsConfigSource implements ConfigSource {
// host.docker.internal: how Lambda containers reach Floci when it runs on the host (not in a container).
// A wildcard SAN covers one label, so every two-label service form needs its own entry.
// Package-private so the tests assert against this list instead of copying it.
static final List<String> DEFAULT_SAN_HOSTNAMES = List.of(
"localhost", "127.0.0.1", "0.0.0.0", "*.localhost",
"localhost.floci.io", "*.localhost.floci.io",
"*.execute-api.localhost.floci.io",
"*.execute-api.localhost.localstack.cloud",
"*.cloudfront.localhost.floci.io", "*.cloudfront.localhost",
"host.docker.internal");
static final List<String> DEFAULT_SAN_HOSTNAMES = defaultSanHostnames();
private static List<String> defaultSanHostnames() {
List<String> sans = new ArrayList<>(List.of(
"localhost", "127.0.0.1", "0.0.0.0", "*.localhost",
"localhost.floci.io", "*.localhost.floci.io",
"*.execute-api.localhost.floci.io",
"*.execute-api.localhost.localstack.cloud",
"*.cloudfront.localhost.floci.io", "*.cloudfront.localhost",
"host.docker.internal"));
for (String region : AwsRegions.ALL) {
sans.add("*.dkr.ecr." + region + ".localhost.floci.io");
}
return List.copyOf(sans);
}
private static volatile Path resolvedTlsDir;
@@ -33,7 +33,7 @@ import java.util.regex.Pattern;
public class EcrRegistryDataPlane {
private static final Pattern ECR_HOST = Pattern.compile(
"^([0-9]{12})\\.dkr\\.ecr\\.([a-z0-9-]+)\\.localhost(?::[0-9]+)?$");
"^([0-9]{12})\\.dkr\\.ecr\\.([a-z0-9-]+)\\.localhost(?:\\.floci\\.io)?(?::[0-9]+)?$");
private static final String MANIFESTS_PATH = "/manifests/";
private static final Set<String> HOP_BY_HOP_HEADERS = Set.of(
"connection", "keep-alive", "proxy-authenticate", "proxy-authorization",