diff --git a/docs/services/eks.md b/docs/services/eks.md index 4d42f65bf8..fc9de75cb4 100644 --- a/docs/services/eks.md +++ b/docs/services/eks.md @@ -46,7 +46,9 @@ running EC2 instance, and attached instance profile. Missing/deleted entries, re revoked sessions and terminated instances are rejected without falling back to administrator access. The existing k3s webhook cache can retain a successful authentication for up to 30 seconds. -New cluster webhook configurations carry the target account, region and creation timestamp. +New cluster webhook configurations carry the target account, region and creation timestamp in the URL path. +Kubernetes client-go replaces server URL query parameters when sending TokenReview requests, so +worker scope must not depend on those parameters. Recreate older local clusters before using worker authentication; a legacy unscoped webhook rejects instance credentials. Obtain fresh IMDS credentials after upgrading so the session includes the stable role ID. diff --git a/src/main/java/io/github/hectorvent/floci/services/eks/EksClusterManager.java b/src/main/java/io/github/hectorvent/floci/services/eks/EksClusterManager.java index 153a3a5d9f..7a2ba7bd14 100644 --- a/src/main/java/io/github/hectorvent/floci/services/eks/EksClusterManager.java +++ b/src/main/java/io/github/hectorvent/floci/services/eks/EksClusterManager.java @@ -700,8 +700,9 @@ public class EksClusterManager { } static String webhookPath(Cluster cluster) { - return webhookPath(cluster.getName()) + "?accountId=" + cluster.getAccountId() - + "®ion=" + cluster.getArn().split(":", 6)[3] + "&createdAt=" + cluster.getCreatedAt(); + // client-go replaces a server URL query when constructing its TokenReview request. + return webhookPath(cluster.getName()) + "/scope/" + cluster.getAccountId() + + "/" + cluster.getArn().split(":", 6)[3] + "/" + cluster.getCreatedAt(); } static String webhookPath(String clusterName) { diff --git a/src/main/java/io/github/hectorvent/floci/services/eks/EksTokenWebhookController.java b/src/main/java/io/github/hectorvent/floci/services/eks/EksTokenWebhookController.java index 2d6ead6026..00f2f991e7 100644 --- a/src/main/java/io/github/hectorvent/floci/services/eks/EksTokenWebhookController.java +++ b/src/main/java/io/github/hectorvent/floci/services/eks/EksTokenWebhookController.java @@ -24,6 +24,11 @@ import java.util.Optional; * the request signature, expiration, and signed cluster ID before resolving worker access entries. * Non-worker credentials retain the legacy cluster-admin compatibility behavior. * + *
New clusters use {@code token-webhook/scope/{accountId}/{region}/{createdAt}}, keeping + * scope in the path because Kubernetes client-go replaces URL query parameters. The base + * {@code token-webhook} route retains query-parameter scope for legacy compatibility; + * unscoped requests cannot authenticate workers. + * *
This is Floci plumbing under the {@code _floci/...} namespace, not an AWS API.
*/
@ApplicationScoped
@@ -42,6 +47,16 @@ public class EksTokenWebhookController {
this.authentication = authentication;
}
+ @POST
+ @Path("scope/{accountId}/{region}/{createdAt}")
+ public Response reviewScoped(@PathParam("clusterName") String clusterName,
+ @PathParam("accountId") String accountId,
+ @PathParam("region") String region,
+ @PathParam("createdAt") String createdAt,
+ Map