mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(apigateway): mark custom-domain routed requests so S3 virtual-host does not claim them (#4966)
A custom domain under the endpoint suffix (e.g. api.mycorp.localhost) was rewritten to /execute-api/... by ApiGatewayCustomDomainFilter, then S3VirtualHostFilter read the host as the dotted bucket "api.mycorp" and prepended it to the path, so S3 answered NoSuchBucket. ApiGatewayCustomDomainFilter now sets a server-side ROUTED_PROPERTY marker when it rewrites, and S3VirtualHostFilter skips marked requests, the same idiom already used for CloudFront distributions and Cognito custom domains.
This commit is contained in:
1 parent
b679fe2312
commit
832bd97966
5 files changed
+75
-4
No files matched your search
+4
@@ -33,6 +33,9 @@ import java.net.URI;
|
||||
@ApplicationScoped
|
||||
public class ApiGatewayCustomDomainFilter implements ContainerRequestFilter {
|
||||
|
||||
/** Set on requests this filter rewrote, so later Host filters do not claim them again. */
|
||||
public static final String ROUTED_PROPERTY = ApiGatewayCustomDomainFilter.class.getName() + ".routed";
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(ApiGatewayCustomDomainFilter.class);
|
||||
private static final String REGIONAL_SUFFIX = ".regional.local";
|
||||
|
||||
@@ -120,6 +123,7 @@ public class ApiGatewayCustomDomainFilter implements ContainerRequestFilter {
|
||||
routeContext.routeToRestApi();
|
||||
}
|
||||
routeContext.recordSignedRequestPath(path);
|
||||
requestContext.setProperty(ROUTED_PROPERTY, Boolean.TRUE);
|
||||
requestContext.setRequestUri(newUri);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import io.github.hectorvent.floci.core.common.AwsRegions;
|
||||
import io.github.hectorvent.floci.core.common.RequestHost;
|
||||
import io.github.hectorvent.floci.core.common.dns.EmbeddedDnsServer;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerDetector;
|
||||
import io.github.hectorvent.floci.services.apigateway.ApiGatewayCustomDomainFilter;
|
||||
import io.github.hectorvent.floci.services.cloudfront.CloudFrontDistributionFilter;
|
||||
import io.github.hectorvent.floci.services.cognito.CognitoCustomDomainFilter;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
@@ -160,10 +161,11 @@ public class S3VirtualHostFilter implements ContainerRequestFilter {
|
||||
return;
|
||||
}
|
||||
|
||||
// A higher-priority Host filter (CloudFront, Cognito custom domain) may have already
|
||||
// routed this request. Use its server-side marker rather than trusting a
|
||||
// user-controlled path prefix.
|
||||
if (Boolean.TRUE.equals(requestContext.getProperty(CloudFrontDistributionFilter.ROUTED_PROPERTY))
|
||||
// A higher-priority Host filter (API Gateway custom domain, CloudFront, Cognito custom
|
||||
// domain) may have already routed this request. Use its server-side marker rather than
|
||||
// trusting a user-controlled path prefix.
|
||||
if (Boolean.TRUE.equals(requestContext.getProperty(ApiGatewayCustomDomainFilter.ROUTED_PROPERTY))
|
||||
|| Boolean.TRUE.equals(requestContext.getProperty(CloudFrontDistributionFilter.ROUTED_PROPERTY))
|
||||
|| requestContext.getProperty(CognitoCustomDomainFilter.POOL_PROPERTY) != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user