mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
fix(apigateway): authorize management calls against the path ARN they name (#6825)
This commit is contained in:
1 parent
c3fdacc3ce
commit
981b885348
8 files changed
+391
-10
No files matched your search
+12
-2
@@ -1525,7 +1525,7 @@ action is denied. The routed protocol determines the status, not just the reques
|
||||
|
||||
A request is checked against the resources it names. Floci builds their ARNs itself for S3, Lambda,
|
||||
SQS, SNS, DynamoDB, Kinesis, SSM, KMS, IAM, Resource Groups, EventBridge Scheduler, EventBridge
|
||||
Pipes, Aurora DSQL, EKS, CloudWatch Logs, Secrets Manager and STS. For Elastic Load Balancing, ECR,
|
||||
Pipes, Aurora DSQL, EKS, API Gateway, CloudWatch Logs, Secrets Manager and STS. For Elastic Load Balancing, ECR,
|
||||
Step Functions, EventBridge, Amazon Cognito user pools and identity pools, Amazon Data Firehose, Cloud
|
||||
Map, ACM, CodePipeline, CodeBuild, Amazon Managed Service for Apache Flink (Kinesis Data Analytics v2),
|
||||
AWS Budgets, Cost and Usage Reports, Service Quotas, Amazon Textract and Amazon Translate they come from a
|
||||
@@ -1612,7 +1612,17 @@ API Gateway's management API, v1 and v2, is checked as `apigateway:` and the HTT
|
||||
method, `apigateway:GET`, `apigateway:POST` and so on, except `RejectDomainNameAccessAssociation`
|
||||
(`apigateway:RejectAccessAssociation`) and `PutRoutingRule` (`apigateway:UpdateRoutingRule`); the
|
||||
v2 routing rule, portal and portal product operations, which AWS checks as actions of their own
|
||||
names, are not served.
|
||||
names, are not served. A management call is checked against the path it names, in the request's
|
||||
Region and partition and with no account, as the
|
||||
[API Gateway ARN reference](https://docs.aws.amazon.com/apigateway/latest/developerguide/arn-format-reference.html)
|
||||
gives it: `GET /restapis/<id>/stages` against `arn:aws:apigateway:<region>::/restapis/<id>/stages`.
|
||||
The `/v2` that starts an HTTP or WebSocket API path is not part of the resource, so `GET /v2/apis`
|
||||
is checked against `arn:aws:apigateway:<region>::/apis`. The path is read as the router reads it,
|
||||
without a trailing `/`: each segment decoded, then `.` dropped and `..` resolved, so `/restapis/%61bc`
|
||||
and `/restapis/x/%2E%2E/abc` are both checked against `::/restapis/abc`, the API they reach, and a
|
||||
stage keeps its name as written, `::/apis/<id>/stages/$default`. Only the ARN a
|
||||
tagging route names, everything after `/tags/` whether its slashes are sent encoded or not, is
|
||||
re-encoded, in SigV4 canonical form, as the `Tags` resource's `/tags/<UrlEncodedResourceARN>` gives it.
|
||||
|
||||
A Scheduler request is checked against `schedule/<group>/<name>`, the group from the body's
|
||||
`GroupName` on a create or an update, from `groupName` otherwise, and `default` when neither names
|
||||
|
||||
@@ -1638,7 +1638,8 @@ public class IamEnforcementFilter implements ContainerRequestFilter {
|
||||
/**
|
||||
* Logs, Secrets Manager and KMS targets depend on the serving operation and the request's partition, STS
|
||||
* targets on the serving operation;
|
||||
* Scheduler and Pipes targets on the request's partition, which those services mint their ARNs in; and the
|
||||
* Scheduler and Pipes targets on the request's partition, which those services mint their ARNs in, as are
|
||||
* API Gateway's path ARNs; and the
|
||||
* targets of a namespace the table of request resources reads on {@code operation}, the one the request is
|
||||
* dispatched as (see {@link RequestResources}).
|
||||
*/
|
||||
@@ -1656,7 +1657,8 @@ public class IamEnforcementFilter implements ContainerRequestFilter {
|
||||
if ("sts".equals(credentialScope)) {
|
||||
return arnBuilder.buildStsResources(action, ctx);
|
||||
}
|
||||
if ("scheduler".equals(credentialScope) || "pipes".equals(credentialScope) || "dsql".equals(credentialScope)) {
|
||||
if ("scheduler".equals(credentialScope) || "pipes".equals(credentialScope) || "dsql".equals(credentialScope)
|
||||
|| "apigateway".equals(credentialScope)) {
|
||||
return arnBuilder.buildResources(credentialScope, ctx, region, accountId, requestPartition());
|
||||
}
|
||||
return arnBuilder.buildResources(credentialScope, operation, ctx, region, accountId,
|
||||
|
||||
@@ -11,6 +11,7 @@ import io.github.hectorvent.floci.core.common.RequestResources;
|
||||
import io.github.hectorvent.floci.core.common.ServicePrincipals;
|
||||
import io.github.hectorvent.floci.core.common.SigV4CredentialScope;
|
||||
import io.github.hectorvent.floci.core.common.StoredResourceArns;
|
||||
import io.github.hectorvent.floci.core.common.auth.SigV4Canonicalization;
|
||||
import io.github.hectorvent.floci.services.cloudwatch.logs.LogGroupTagTarget;
|
||||
import io.github.hectorvent.floci.services.eks.EksController;
|
||||
import io.github.hectorvent.floci.services.eks.EksService;
|
||||
@@ -38,6 +39,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -70,6 +72,12 @@ public class ResourceArnBuilder {
|
||||
/** Where an S3 Control tagging route carries the ARN of the resource it acts on. */
|
||||
private static final String S3_CONTROL_TAGS_PREFIX = "/v20180820/tags/";
|
||||
|
||||
/** The segment that starts an API Gateway v2 management path, and is not part of the resource it names. */
|
||||
private static final String API_GATEWAY_V2_SEGMENT = "v2";
|
||||
|
||||
/** The segment a tagging route names before the ARN it tags, which it captures whole, slashes included. */
|
||||
private static final String API_GATEWAY_TAGS_SEGMENT = "tags";
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
/**
|
||||
* Looked up lazily through a provider: this builder is constructed by the enforcement filter,
|
||||
@@ -190,6 +198,7 @@ public class ResourceArnBuilder {
|
||||
case "pipes" -> List.of(buildPipesArn(path, ctx, region, accountId, partition));
|
||||
case "dsql" -> List.of(buildDsqlArn(path, ctx, region, accountId, partition));
|
||||
case "eks" -> List.of(buildEksArn(path, ctx, region, accountId));
|
||||
case "apigateway" -> List.of(buildApiGatewayArn(ctx, region, partition));
|
||||
default -> namedResources(credentialScope, operation, ctx, region, accountId, partition);
|
||||
};
|
||||
}
|
||||
@@ -1196,6 +1205,48 @@ public class ResourceArnBuilder {
|
||||
return taggedResource(ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* API Gateway authorizes a management call as its HTTP method on the path it names, in the Region serving
|
||||
* it and with no account: {@code GET /restapis/abc/stages} acts on
|
||||
* {@code arn:<partition>:apigateway:<region>::/restapis/abc/stages}. The path is read as the router reads
|
||||
* it: each segment decoded, then {@code .} dropped and {@code ..} resolved, then empty segments dropped, so
|
||||
* {@code /restapis/%61bc}, {@code /restapis/x/%2E%2E/abc} and {@code /restapis//abc} all act on
|
||||
* {@code ::/restapis/abc}, the API they reach, and a stage keeps
|
||||
* its name as written, {@code ::/apis/<id>/stages/$default}. The {@code /v2} that starts an HTTP or
|
||||
* WebSocket API path is not part of its resource, so {@code GET /v2/apis} acts on {@code ::/apis}. Only the
|
||||
* ARN a tagging route names, everything after {@code /tags/}, is re-encoded, in SigV4 canonical form, as AWS
|
||||
* names that resource {@code /tags/<UrlEncodedResourceARN>}; elsewhere a decoded {@code %} or {@code /}
|
||||
* stays escaped, so a segment cannot pass for more than one.
|
||||
*/
|
||||
private static String buildApiGatewayArn(ContainerRequestContext ctx, String region, String partition) {
|
||||
String[] raw = IamActionRegistry.routedPath(ctx.getUriInfo()).split("/", -1);
|
||||
List<String> segments = new ArrayList<>();
|
||||
for (int i = 1; i < raw.length; i++) {
|
||||
String segment = pathSegment(raw[i]);
|
||||
if (segment.equals("..")) {
|
||||
if (!segments.isEmpty()) {
|
||||
segments.removeLast();
|
||||
}
|
||||
} else if (!segment.equals(".")) {
|
||||
segments.add(segment);
|
||||
}
|
||||
}
|
||||
segments.removeIf(String::isEmpty);
|
||||
if (!segments.isEmpty() && segments.getFirst().equals(API_GATEWAY_V2_SEGMENT)) {
|
||||
segments.removeFirst();
|
||||
}
|
||||
if (segments.size() > 1 && segments.getFirst().equals(API_GATEWAY_TAGS_SEGMENT)) {
|
||||
String tagged = String.join("/", segments.subList(1, segments.size()));
|
||||
return new AwsArnUtils.Arn(partition, "apigateway", region, "",
|
||||
"/" + API_GATEWAY_TAGS_SEGMENT + "/" + SigV4Canonicalization.uriEncode(tagged)).toString();
|
||||
}
|
||||
StringJoiner resource = new StringJoiner("/", "/", "");
|
||||
for (String segment : segments) {
|
||||
resource.add(segment.replace("%", "%25").replace("/", "%2F"));
|
||||
}
|
||||
return new AwsArnUtils.Arn(partition, "apigateway", region, "", resource.toString()).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* The resource of an EKS route, as the Service Reference gives it, in the caller's account, where EKS
|
||||
* looks everything up. A cluster is the ARN EKS holds it under, or for one it holds none of, the ARN a
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
"_source": {"generator": "tools/aws/regen_iam_request_resources.py", "reference": "https://servicereference.us-east-1.amazonaws.com/", "botocore": "botocore 1.43.113 (installed package)", "retrieved": "2026-10-29", "note": "make iam-request-resources-check re-derives every operation's resources from botocore; make iam-request-resources-verify checks every action, type and format against AWS."},
|
||||
"namespaces": {"acm": ["acm"], "budgets": ["budgets"], "codebuild": ["codebuild"], "codepipeline": ["codepipeline"], "cognito-identity": ["cognito-identity"], "cognito-idp": ["cognito-idp"], "cur": ["cur"], "ecr": ["ecr"], "elasticloadbalancing": ["elb", "elbv2"], "events": ["events"], "firehose": ["firehose"], "kinesisanalytics": ["kinesisanalyticsv2"], "servicediscovery": ["servicediscovery"], "servicequotas": ["service-quotas"], "states": ["stepfunctions"], "textract": ["textract"], "translate": ["translate"]},
|
||||
"clientsNotRead": {"eventbridgev2": "EventBridge V2, the AWSEventsV2 target over Smithy RPC v2 CBOR on the eventsv2 endpoint, which Floci does not serve; its operations share EventBridge's names and name their resources by other members", "kinesisanalytics": "Kinesis Data Analytics v1, SQL applications on the KinesisAnalytics_20150814 target, which Floci does not serve (it serves v2, kinesisanalyticsv2); its operations share v2's names and name their resources by other members"},
|
||||
"handBuilt": ["dsql", "dynamodb", "eks", "iam", "kinesis", "kms", "lambda", "logs", "pipes", "resource-groups", "s3", "scheduler", "secretsmanager", "sns", "sqs", "ssm", "sts"],
|
||||
"notCovered": {"access-analyzer": "REST: its requests name their resources in the path, which RequestResources does not read yet", "account": "REST: its requests name their resources in the path, which RequestResources does not read yet", "airflow": "REST: its requests name their resources in the path, which RequestResources does not read yet", "apigateway": "REST: its requests name their resources in the path, which RequestResources does not read yet", "app-integrations": "REST: its requests name their resources in the path, which RequestResources does not read yet", "appconfig": "REST: its requests name their resources in the path, which RequestResources does not read yet", "application-autoscaling": "not read yet: a scalable target's ARN ends in an id the service mints, `scalable-target/<id>`, while its requests name the target by ServiceNamespace, ResourceId and ScalableDimension, so its resource is the stored ARN those three find, which RequestResources has no lookup for yet; read as a member, ResourceId would fill that id", "appsync": "REST: its requests name their resources in the path, which RequestResources does not read yet", "aps": "REST: its requests name their resources in the path, which RequestResources does not read yet", "athena": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "autoscaling": "not read yet: AWS's group and launch configuration ARNs carry an id the service mints, `autoScalingGroup:<id>:autoScalingGroupName/<name>`, while Floci mints `autoScalingGroup:<name>`, which other services (ECS capacity providers) read back; the mint is fixed first", "aws-marketplace": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "backup": "REST: its requests name their resources in the path, which RequestResources does not read yet", "batch": "REST: its requests name their resources in the path, which RequestResources does not read yet", "bcm-data-exports": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "bcm-pricing-calculator": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "bedrock": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "bedrock-agentcore": "REST: its requests name their resources in the path, which RequestResources does not read yet", "ce": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "cloudformation": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "cloudfront": "REST: its requests name their resources in the path, which RequestResources does not read yet", "cloudhsm": "not read yet: its ARN formats end in ${CloudHsmClusterInstanceName} and ${CloudHsmBackupInstanceName}, names, while its requests give ClusterId and BackupId, ids, which the rule does not fill a name from, so nearly every operation needs a correction", "cloudtrail": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "cloudwatch": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "codeartifact": "REST: its requests name their resources in the path, which RequestResources does not read yet", "codedeploy": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "codeguru-reviewer": "REST: its requests name their resources in the path, which RequestResources does not read yet", "comprehend": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "config": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "connect": "REST: its requests name their resources in the path, which RequestResources does not read yet", "controlcatalog": "REST: its requests name their resources in the path, which RequestResources does not read yet", "controltower": "REST: its requests name their resources in the path, which RequestResources does not read yet", "datasync": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "detective": "REST: its requests name their resources in the path, which RequestResources does not read yet", "dlm": "REST: its requests name their resources in the path, which RequestResources does not read yet", "dms": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "ec2": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "ecs": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "elasticache": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "elasticbeanstalk": "not read yet: a later batch, with the tests that show its ARNs are the onLine truncated
|
||||
"handBuilt": ["apigateway", "dsql", "dynamodb", "eks", "iam", "kinesis", "kms", "lambda", "logs", "pipes", "resource-groups", "s3", "scheduler", "secretsmanager", "sns", "sqs", "ssm", "sts"],
|
||||
"notCovered": {"access-analyzer": "REST: its requests name their resources in the path, which RequestResources does not read yet", "account": "REST: its requests name their resources in the path, which RequestResources does not read yet", "airflow": "REST: its requests name their resources in the path, which RequestResources does not read yet", "app-integrations": "REST: its requests name their resources in the path, which RequestResources does not read yet", "appconfig": "REST: its requests name their resources in the path, which RequestResources does not read yet", "application-autoscaling": "not read yet: a scalable target's ARN ends in an id the service mints, `scalable-target/<id>`, while its requests name the target by ServiceNamespace, ResourceId and ScalableDimension, so its resource is the stored ARN those three find, which RequestResources has no lookup for yet; read as a member, ResourceId would fill that id", "appsync": "REST: its requests name their resources in the path, which RequestResources does not read yet", "aps": "REST: its requests name their resources in the path, which RequestResources does not read yet", "athena": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "autoscaling": "not read yet: AWS's group and launch configuration ARNs carry an id the service mints, `autoScalingGroup:<id>:autoScalingGroupName/<name>`, while Floci mints `autoScalingGroup:<name>`, which other services (ECS capacity providers) read back; the mint is fixed first", "aws-marketplace": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "backup": "REST: its requests name their resources in the path, which RequestResources does not read yet", "batch": "REST: its requests name their resources in the path, which RequestResources does not read yet", "bcm-data-exports": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "bcm-pricing-calculator": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "bedrock": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "bedrock-agentcore": "REST: its requests name their resources in the path, which RequestResources does not read yet", "ce": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "cloudformation": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "cloudfront": "REST: its requests name their resources in the path, which RequestResources does not read yet", "cloudhsm": "not read yet: its ARN formats end in ${CloudHsmClusterInstanceName} and ${CloudHsmBackupInstanceName}, names, while its requests give ClusterId and BackupId, ids, which the rule does not fill a name from, so nearly every operation needs a correction", "cloudtrail": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "cloudwatch": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "codeartifact": "REST: its requests name their resources in the path, which RequestResources does not read yet", "codedeploy": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "codeguru-reviewer": "REST: its requests name their resources in the path, which RequestResources does not read yet", "comprehend": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "config": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "connect": "REST: its requests name their resources in the path, which RequestResources does not read yet", "controlcatalog": "REST: its requests name their resources in the path, which RequestResources does not read yet", "controltower": "REST: its requests name their resources in the path, which RequestResources does not read yet", "datasync": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "detective": "REST: its requests name their resources in the path, which RequestResources does not read yet", "dlm": "REST: its requests name their resources in the path, which RequestResources does not read yet", "dms": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "ec2": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "ecs": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "elasticache": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "elasticbeanstalk": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "elasticfilesystem": "REST: its requests name their resources in the path, which RequestLine truncated
|
||||
"otherNamespaces": ["a4b", "account-access", "acm-pca", "aco-automation", "agent-registry", "aidevops", "aiops", "airflow-serverless", "amplify", "amplifybackend", "amplifyuibuilder", "aoss", "appfabric", "appflow", "application-signals", "application-signals-mcp", "appmesh", "appmesh-preview", "apprunner", "appstream", "apptest", "arc-region-switch", "arc-zonal-shift", "artifact", "assurance", "auditmanager", "aws-external-anthropic", "b2bi", "backup-gateway", "backup-search", "bedrock-mantle", "bedrock-websearch", "billing", "billingconductor", "braket", "bugbust", "cases", "cassandra", "chatbot", "chime", "cleanrooms", "cleanrooms-ml", "cloud9", "clouddirectory", "cloudfront-keyvaluestore", "cloudsearch", "cloudshell", "cloudtrail-data", "codecatalyst", "codecommit", "codeconnections", "codeguru-profiler", "codeguru-security", "codestar-connections", "codestar-notifications", "codewhisperer", "cognito-sync", "connect-campaigns", "consoleapp", "continuum", "databrew", "dataexchange", "datapipeline", "datazone", "dax", "deadline", "devicefarm", "devops-guru", "directconnect", "docdb-elastic", "drs", "ds", "ds-data", "ebs", "ec2-instance-connect", "ecr-public", "eks-auth", "elastictranscoder", "elemental-appliances-software", "elemental-inference", "elemental-support-cases", "emr-containers", "end-user-messaging", "entityresolution", "evs", "finspace", "finspace-api", "fms", "forecast", "frauddetector", "freertos", "fsx", "gamelift", "gameliftstreams", "geo", "geo-maps", "geo-places", "geo-routes", "glacier", "grafana", "greengrass", "groundstation", "health", "health-agent", "healthlake", "honeycode", "identity-sync", "imagebuilder", "interconnect", "internetmonitor", "invoicing", "iotanalytics", "iotdeviceadvisor", "iotfleethub", "iotfleetwise", "iotjobsdata", "iotmanagedintegrations", "iotsitewise", "iottwinmaker", "iotwireless", "iq", "iq-permission", "ivs", "ivschat", "kafka-cluster", "kafkaconnect", "kendra", "kendra-ranking", "kinesisvideo", "launchwizard", "lex", "license-manager", "license-manager-linux-subscriptions", "license-manager-user-subscriptions", "lookoutequipment", "lookoutmetrics", "lookoutvision", "m2", "machinelearning", "managedblockchain", "mapcredits", "mediaconnect", "mediaconvert", "medialive", "mediapackage", "mediapackage-vod", "mediapackagev2", "mediastore", "mediatailor", "medical-imaging", "mgh", "mgn", "migrationhub-orchestrator", "mobiletargeting", "monitron", "mpa", "neptune-db", "neptune-graph", "network-security-manager", "networkflowmonitor", "networkmanager", "networkmonitor", "nimble", "notifications", "notifications-contacts", "nova-act", "observabilityadmin", "odb", "omics", "one", "opensearch", "opsworks", "osis", "outposts", "panorama", "partnercentral", "payment-cryptography", "payments", "pca-connector-ad", "pca-connector-scep", "pcs", "personalize", "pi", "polly", "private-networks", "profile", "proton", "purchase-orders", "q", "qapps", "qbusiness", "qdeveloper", "qldb", "quicksight", "rbin", "rds-db", "refactor-spaces", "repostspace", "resiliencehub", "robomaker", "rolesanywhere", "route53-recovery-cluster", "route53-recovery-control-config", "route53-recovery-readiness", "route53globalresolver", "route53profiles", "rtbfabric", "s3-object-lambda", "s3-outposts", "s3express", "s3files", "sagemaker-geospatial", "sagemaker-mlflow", "savingsplans", "schemas", "scn", "sdb", "security-ir", "securityagent", "securitylake", "serverlessrepo", "shield", "signer", "simspaceweaver", "sms-voice", "snow-device-management", "social-messaging", "sqlworkbench", "ssm-contacts", "ssm-incidents", "ssm-quicksetup", "ssm-sap", "storagegateway", "supportauthz", "synthetics", "thinclient", "timestream", "tnb", "transform", "transform-custom", "trustedadvisor", "ts", "vendor-insights", "voiceid", "vpc-lattice", "vpc-lattice-svcs", "vpce", "waf", "waf-regional", "wellarchitected", "wickr", "wisdom", "workdocs", "worklink", "workmail", "workmailmessageflow", "workspaces", "workspaces-instances", "workspaces-web", "xray"],
|
||||
"arnFormats": {"acm": {"acme-domain-validation": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}/acme-domain-validation/${AcmeDomainValidationId}", "acme-endpoint": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}", "acme-external-account-binding": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}/acme-external-account-binding/${ExternalAccountBindingId}", "certificate": "arn:${Partition}:acm:${Region}:${Account}:certificate/${CertificateId}"}, "budgets": {"budget": "arn:${Partition}:budgets::${Account}:budget/${BudgetName}", "budgetAction": "arn:${Partition}:budgets::${Account}:budget/${BudgetName}/action/${ActionId}"}, "codebuild": {"build": "arn:${Partition}:codebuild:${Region}:${Account}:build/${BuildId}", "build-batch": "arn:${Partition}:codebuild:${Region}:${Account}:build-batch/${BuildBatchId}", "fleet": "arn:${Partition}:codebuild:${Region}:${Account}:fleet/${FleetName}:${FleetId}", "project": "arn:${Partition}:codebuild:${Region}:${Account}:project/${ProjectName}", "report": "arn:${Partition}:codebuild:${Region}:${Account}:report/${ReportGroupName}:${ReportId}", "report-group": "arn:${Partition}:codebuild:${Region}:${Account}:report-group/${ReportGroupName}", "sandbox": "arn:${Partition}:codebuild:${Region}:${Account}:sandbox/${SandboxId}"}, "codepipeline": {"action": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}/${StageName}/${ActionName}", "actiontype": "arn:${Partition}:codepipeline:${Region}:${Account}:actiontype:${Owner}/${Category}/${Provider}/${Version}", "pipeline": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}", "stage": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}/${StageName}", "webhook": "arn:${Partition}:codepipeline:${Region}:${Account}:webhook:${WebhookName}"}, "cognito-identity": {"identitypool": "arn:${Partition}:cognito-identity:${Region}:${Account}:identitypool/${IdentityPoolId}"}, "cognito-idp": {"userpool": "arn:${Partition}:cognito-idp:${Region}:${Account}:userpool/${UserPoolId}", "webacl": "arn:${Partition}:wafv2:${Region}:${Account}:${Scope}/webacl/${Name}/${Id}"}, "cur": {"cur": "arn:${Partition}:cur:${Region}:${Account}:definition/${ReportName}"}, "ecr": {"repository": "arn:${Partition}:ecr:${Region}:${Account}:repository/${RepositoryName}"}, "elasticloadbalancing": {"listener-rule/app": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener-rule/app/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}/${ListenerRuleId}", "listener-rule/net": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener-rule/net/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}/${ListenerRuleId}", "listener/app": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener/app/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}", "listener/gwy": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener/gwy/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}", "listener/net": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener/net/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}", "loadbalancer": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:loadbalancer/${LoadBalancerName}", "loadbalancer/app/": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:loadbalancer/app/${LoadBalancerName}/${LoadBalancerId}", "loadbalancer/gwy/": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:loadbalancer/gwy/${LoadBalancerName}/${LoadBalancerId}", "loadbalancer/net/": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:loadbalancer/net/${LoadBalancerName}/${LoadBalancerId}", "targetgroup": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:targetgroup/${TargetGroupName}/${TargetGroupId}", "truststore": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:truststore/${TrustStoreName}/${TrustStoreId}"}, "events": {"alias": "arn:${Partition}:kms:${Region}:${Account}:alias/${Alias}", "api-destination": "arn:${Partition}:events:${Region}:${Account}:api-destination/${ApiDestinationName}", "archive": "arn:${Partition}:events:${Region}:${Account}:archive/${ArchiveName}", "connection": "arn:${Partition}:events:${Region}:${Account}:connection/${ConnectionName}", "create-snapshot": "arn:${Partition}:events:${Region}:${Account}:target/create-snapshot", "endpoint": "arn:${Partition}:events:${Region}:${Account}:endpoint/${EndpointName}", "event-bus": "arn:${Partition}:events:${Region}:${Account}:event-bus/${EventBusName}", "event-busv2": "arn:${Partition}:events:${Region}:${Account}:event-busv2/${EventBusName}/${OpaqueId}", "event-source": "arn:${Partition}:events:${Region}::event-source/${EventSourceName}", "event-sourcev2": "arn:${Partition}:events:${Region}:${Account}:event-sourcev2/${SourceType}/${EventSourceName}/${OpaqueId}", "key": "arn:${Partition}:kms:${Region}:${Account}:key/${KeyId}", "reboot-instance": "arn:${Partition}:events:${Region}:${Account}:tarLine truncated
|
||||
"unqualified": {"states": ["statemachine"]},
|
||||
|
||||
@@ -402,6 +402,7 @@ class IamEnforcementFilterTest {
|
||||
+ "SignedHeaders=host, Signature=abc";
|
||||
requestContext.setAccountId("000000000000");
|
||||
requestContext.setRegion("us-east-1");
|
||||
requestContext.setPartition("aws");
|
||||
when(accountResolver.extractAccessKeyId(auth)).thenReturn("AKIAUSER");
|
||||
when(containerRequest.getHeaderString("Authorization")).thenReturn(auth);
|
||||
when(containerRequest.getProperty(AwsProtocolClaimFilter.CLAIM_PROPERTY))
|
||||
@@ -417,7 +418,7 @@ class IamEnforcementFilterTest {
|
||||
|
||||
verify(actionRegistry).resolveRoute("apigateway", containerRequest);
|
||||
verify(actionRegistry, never()).resolveRoute("iam", containerRequest);
|
||||
verify(arnBuilder).buildResources(eq("apigateway"), any(), eq(containerRequest), eq("us-east-1"), eq("000000000000"), eq("aws"));
|
||||
verify(arnBuilder).buildResources("apigateway", containerRequest, "us-east-1", "000000000000", "aws");
|
||||
verify(conditionContextResolver).resolve("apigateway", "apigateway:POST", containerRequest);
|
||||
}
|
||||
|
||||
@@ -446,6 +447,31 @@ class IamEnforcementFilterTest {
|
||||
verify(arnBuilder).buildResources("scheduler", containerRequest, "xx-local-1", "000000000000", "aws-cn");
|
||||
}
|
||||
|
||||
@Test
|
||||
void apiGatewayResourcesAreBuiltInTheRequestsPartition() {
|
||||
// A Region no partition publishes takes the deployment's partition, the one its path ARNs are in.
|
||||
ContainerRequestContext containerRequest = mock(ContainerRequestContext.class);
|
||||
String auth = "AWS4-HMAC-SHA256 Credential=AKIAUSER/20260924/xx-local-1/apigateway/aws4_request, "
|
||||
+ "SignedHeaders=host, Signature=abc";
|
||||
requestContext.setAccountId("000000000000");
|
||||
requestContext.setRegion("xx-local-1");
|
||||
requestContext.setPartition("aws-cn");
|
||||
when(accountResolver.extractAccessKeyId(auth)).thenReturn("AKIAUSER");
|
||||
when(containerRequest.getHeaderString("Authorization")).thenReturn(auth);
|
||||
when(containerRequest.getProperty(AwsProtocolClaimFilter.CLAIM_PROPERTY))
|
||||
.thenReturn(ProtocolClaim.rest());
|
||||
when(catalog.byResourceClass(ApiGatewayController.class))
|
||||
.thenReturn(Optional.of(descriptor("apigateway", ServiceProtocol.REST_JSON,
|
||||
Set.of("apigateway", "execute-api"), ApiGatewayController.class)));
|
||||
when(actionRegistry.resolveRoute("apigateway", containerRequest)).thenReturn("apigateway:GET");
|
||||
when(arnBuilder.buildResources(any(), any(), any(), any(), any())).thenReturn(List.of("*"));
|
||||
when(iamService.resolveCallerContext(eq("AKIAUSER"), any())).thenReturn(CallerContext.of(List.of()));
|
||||
|
||||
newFilter(resourceInfo(ApiGatewayController.class)).filter(containerRequest);
|
||||
|
||||
verify(arnBuilder).buildResources("apigateway", containerRequest, "xx-local-1", "000000000000", "aws-cn");
|
||||
}
|
||||
|
||||
@Test
|
||||
void s3RouteDoesNotUseApiGatewayRules() {
|
||||
ContainerRequestContext containerRequest = mock(ContainerRequestContext.class);
|
||||
|
||||
+229
@@ -0,0 +1,229 @@
|
||||
package io.github.hectorvent.floci.services.iam;
|
||||
|
||||
import io.github.hectorvent.floci.testing.EnforcementFixtures;
|
||||
import io.github.hectorvent.floci.testing.IamEnforcementProfile;
|
||||
import io.github.hectorvent.floci.testing.PartitionCleanup;
|
||||
import io.quarkus.test.common.http.TestHTTPResource;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.junit.TestProfile;
|
||||
import io.restassured.response.ValidatableResponse;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static io.github.hectorvent.floci.testing.EnforcementFixtures.auth;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* API Gateway authorizes a management call as its HTTP method on the path it names,
|
||||
* {@code arn:<partition>:apigateway:<region>::<path>}, with no account and without the {@code /v2} of an HTTP
|
||||
* API path, so a grant or a deny of {@code apigateway:GET} on a path covers that path's reads and no others.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestProfile(IamEnforcementProfile.class)
|
||||
class ApiGatewayPathArnEnforcementIntegrationTest {
|
||||
|
||||
private static final String ADMIN = "test";
|
||||
|
||||
@TestHTTPResource("/")
|
||||
URI baseUri;
|
||||
|
||||
@RegisterExtension
|
||||
final PartitionCleanup cleanup = new PartitionCleanup();
|
||||
|
||||
/** Each user's access key ID, by user name. */
|
||||
private final Map<String, String> keys = new HashMap<>();
|
||||
|
||||
@Test
|
||||
void getRestApisIsCheckedOnTheRestApisPath() {
|
||||
String user = user("apigw-restapis");
|
||||
|
||||
policy(user, allow("apigateway:GET", "arn:aws:apigateway:*::/restapis"));
|
||||
get(user, "/restapis").statusCode(200);
|
||||
|
||||
policy(user, allow("apigateway:GET", "arn:aws:apigateway:*::/restapis/*/stages"));
|
||||
refused(get(user, "/restapis"));
|
||||
|
||||
policy(user, allow("apigateway:GET", "arn:aws:apigateway:eu-west-1::/restapis"));
|
||||
refused(get(user, "/restapis"));
|
||||
|
||||
policy(user, allow("apigateway:*", "*") + ","
|
||||
+ deny("apigateway:GET", "arn:aws:apigateway:us-east-1::/restapis"));
|
||||
refused(get(user, "/restapis"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getStagesIsCheckedOnTheStagesPathOfItsApi() throws Exception {
|
||||
String apiId = createRestApi();
|
||||
String user = user("apigw-stages");
|
||||
|
||||
policy(user, allow("apigateway:GET", "arn:aws:apigateway:*::/restapis/*/stages"));
|
||||
get(user, "/restapis/" + apiId + "/stages").statusCode(200);
|
||||
get(user, "/restapis/" + encodedFirstCharacter(apiId) + "/stages").statusCode(200);
|
||||
get(user, "/restapis/x/%2E%2E/" + apiId + "/stages").statusCode(200);
|
||||
assertReached(getAsWritten(user, "/restapis//" + apiId + "/stages"));
|
||||
assertReached(getAsWritten(user, "/restapis/x/%2E%2E//" + apiId + "/stages"));
|
||||
|
||||
policy(user, allow("apigateway:GET", "arn:aws:apigateway:*::/restapis"));
|
||||
refused(get(user, "/restapis/" + apiId + "/stages"));
|
||||
|
||||
policy(user, allow("apigateway:*", "*") + ","
|
||||
+ deny("apigateway:GET", "arn:aws:apigateway:*::/restapis/" + apiId + "/stages"));
|
||||
refused(get(user, "/restapis/" + apiId + "/stages"));
|
||||
refused(get(user, "/restapis/" + encodedFirstCharacter(apiId) + "/stages"));
|
||||
refused(get(user, "/restapis/x/%2E%2E/" + apiId + "/stages"));
|
||||
assertRefused(getAsWritten(user, "/restapis//" + apiId + "/stages"));
|
||||
assertRefused(getAsWritten(user, "/restapis/x/%2E%2E//" + apiId + "/stages"));
|
||||
get(user, "/restapis").statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getApisIsCheckedOnTheApisPathWithoutItsV2Prefix() {
|
||||
String user = user("apigw-apis");
|
||||
|
||||
policy(user, allow("apigateway:GET", "arn:aws:apigateway:*::/apis"));
|
||||
get(user, "/v2/apis").statusCode(200);
|
||||
|
||||
policy(user, allow("apigateway:GET", "arn:aws:apigateway:*::/v2/apis"));
|
||||
refused(get(user, "/v2/apis"));
|
||||
|
||||
policy(user, allow("apigateway:*", "*") + ","
|
||||
+ deny("apigateway:GET", "arn:aws:apigateway:*::/apis"));
|
||||
refused(get(user, "/v2/apis"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getStageIsCheckedOnTheStageNameAsWritten() {
|
||||
String apiId = createHttpApiWithDefaultStage();
|
||||
String user = user("apigw-default-stage");
|
||||
|
||||
policy(user, allow("apigateway:GET", "arn:aws:apigateway:*::/apis/" + apiId + "/stages/$default"));
|
||||
get(user, "/v2/apis/" + apiId + "/stages/$default").statusCode(200);
|
||||
get(user, "/v2/apis/" + apiId + "/stages/%24default").statusCode(200);
|
||||
|
||||
policy(user, allow("apigateway:*", "*") + ","
|
||||
+ deny("apigateway:GET", "arn:aws:apigateway:*::/apis/" + apiId + "/stages/$default"));
|
||||
refused(get(user, "/v2/apis/" + apiId + "/stages/%24default"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getTagsIsCheckedOnTheEncodedArnItTagsHoweverItIsSent() {
|
||||
String apiId = createHttpApiWithDefaultStage();
|
||||
String apiArn = "arn:aws:apigateway:us-east-1::/apis/" + apiId;
|
||||
String encoded = "arn%3Aaws%3Aapigateway%3Aus-east-1%3A%3A%2Fapis%2F" + apiId;
|
||||
String user = user("apigw-tags");
|
||||
|
||||
policy(user, allow("apigateway:GET", "arn:aws:apigateway:us-east-1::/tags/" + encoded));
|
||||
get(user, "/v2/tags/" + apiArn).statusCode(200);
|
||||
get(user, "/v2/tags/" + encoded).statusCode(200);
|
||||
|
||||
policy(user, allow("apigateway:*", "*") + ","
|
||||
+ deny("apigateway:GET", "arn:aws:apigateway:us-east-1::/tags/" + encoded));
|
||||
refused(get(user, "/v2/tags/" + apiArn));
|
||||
refused(get(user, "/v2/tags/" + encoded));
|
||||
}
|
||||
|
||||
private String createHttpApiWithDefaultStage() {
|
||||
String apiId = given()
|
||||
.header("Authorization", auth(ADMIN, "apigateway"))
|
||||
.contentType("application/json")
|
||||
.body("{\"name\":\"apigw-path-" + suffix() + "\",\"protocolType\":\"HTTP\"}")
|
||||
.when().post("/v2/apis")
|
||||
.then().statusCode(201)
|
||||
.extract().path("apiId");
|
||||
cleanup.register(() -> given().header("Authorization", auth(ADMIN, "apigateway"))
|
||||
.delete("/v2/apis/" + apiId));
|
||||
given()
|
||||
.header("Authorization", auth(ADMIN, "apigateway"))
|
||||
.contentType("application/json")
|
||||
.body("{\"stageName\":\"$default\"}")
|
||||
.when().post("/v2/apis/" + apiId + "/stages")
|
||||
.then().statusCode(201);
|
||||
return apiId;
|
||||
}
|
||||
|
||||
private String createRestApi() {
|
||||
String apiId = given()
|
||||
.header("Authorization", auth(ADMIN, "apigateway"))
|
||||
.contentType("application/json")
|
||||
.body("{\"name\":\"apigw-path-" + suffix() + "\"}")
|
||||
.when().post("/restapis")
|
||||
.then().statusCode(201)
|
||||
.extract().path("id");
|
||||
cleanup.register(() -> given().header("Authorization", auth(ADMIN, "apigateway"))
|
||||
.delete("/restapis/" + apiId));
|
||||
return apiId;
|
||||
}
|
||||
|
||||
private ValidatableResponse get(String user, String path) {
|
||||
return given().urlEncodingEnabled(false)
|
||||
.header("Authorization", auth(keys.get(user), "apigateway")).get(path).then();
|
||||
}
|
||||
|
||||
/** Sends {@code path} with its empty segments, which RestAssured collapses before sending. */
|
||||
private HttpResponse<String> getAsWritten(String user, String path) throws Exception {
|
||||
URI uri = URI.create(baseUri.getScheme() + "://" + baseUri.getRawAuthority() + path);
|
||||
try (HttpClient client = HttpClient.newHttpClient()) {
|
||||
return client.send(HttpRequest.newBuilder(uri)
|
||||
.header("Authorization", auth(keys.get(user), "apigateway")).GET().build(),
|
||||
HttpResponse.BodyHandlers.ofString());
|
||||
}
|
||||
}
|
||||
|
||||
private static void assertReached(HttpResponse<String> response) {
|
||||
assertEquals(200, response.statusCode(), response.body());
|
||||
assertThat(response.body(), containsString("\"item\""));
|
||||
}
|
||||
|
||||
private static void assertRefused(HttpResponse<String> response) {
|
||||
assertEquals(403, response.statusCode(), response.body());
|
||||
assertThat(response.body(), containsString("AccessDeniedException"));
|
||||
assertThat(response.body(), containsString("apigateway:GET"));
|
||||
}
|
||||
|
||||
/** {@code id} with its first character percent-encoded, a path that routes to the same API. */
|
||||
private static String encodedFirstCharacter(String id) {
|
||||
return "%%%02X".formatted((int) id.charAt(0)) + id.substring(1);
|
||||
}
|
||||
|
||||
private static void refused(ValidatableResponse response) {
|
||||
response.statusCode(403)
|
||||
.body(containsString("AccessDeniedException"))
|
||||
.body(containsString("apigateway:GET"));
|
||||
}
|
||||
|
||||
private static String allow(String action, String resource) {
|
||||
return "{\"Effect\":\"Allow\",\"Action\":\"" + action + "\",\"Resource\":\"" + resource + "\"}";
|
||||
}
|
||||
|
||||
private static String deny(String action, String resource) {
|
||||
return "{\"Effect\":\"Deny\",\"Action\":\"" + action + "\",\"Resource\":\"" + resource + "\"}";
|
||||
}
|
||||
|
||||
/** Replaces the user's one inline policy. */
|
||||
private void policy(String user, String statements) {
|
||||
EnforcementFixtures.putUserPolicy(baseUri.getPort(), auth(ADMIN, "iam"), user, "p",
|
||||
"{\"Version\":\"2012-10-17\",\"Statement\":[" + statements + "]}");
|
||||
}
|
||||
|
||||
private String user(String name) {
|
||||
String userName = name + "-" + suffix();
|
||||
String accessKeyId = EnforcementFixtures.createUser(cleanup, baseUri.getPort(), auth(ADMIN, "iam"), userName)
|
||||
.accessKeyId();
|
||||
keys.put(userName, accessKeyId);
|
||||
return userName;
|
||||
}
|
||||
|
||||
private static String suffix() {
|
||||
return Long.toString(System.nanoTime(), 36);
|
||||
}
|
||||
}
|
||||
@@ -1896,6 +1896,70 @@ class ResourceArnBuilderTest {
|
||||
builder.buildResources("dsql", ctx, "polygondwanaland-west-1", "000000000000", "aws-cn"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void apiGatewayRoutesResolveThePathTheyNameWithNoAccount() {
|
||||
request("/restapis/abc123/stages");
|
||||
assertEquals(List.of("arn:aws:apigateway:us-east-1::/restapis/abc123/stages"),
|
||||
builder.buildResources("apigateway", ctx, "us-east-1", ACCOUNT));
|
||||
// Each segment is decoded as the router decodes it, so an encoded id names the API it routes to.
|
||||
request("/restapis/%61bc123/stages");
|
||||
assertEquals(List.of("arn:aws:apigateway:us-east-1::/restapis/abc123/stages"),
|
||||
builder.buildResources("apigateway", ctx, "us-east-1", ACCOUNT));
|
||||
// Dot segments are resolved after decoding, as the router resolves them.
|
||||
request("/restapis/x/%2E%2E/abc123/stages");
|
||||
assertEquals(List.of("arn:aws:apigateway:us-east-1::/restapis/abc123/stages"),
|
||||
builder.buildResources("apigateway", ctx, "us-east-1", ACCOUNT));
|
||||
request("/restapis/%2e/abc123");
|
||||
assertEquals(List.of("arn:aws:apigateway:us-east-1::/restapis/abc123"),
|
||||
builder.buildResources("apigateway", ctx, "us-east-1", ACCOUNT));
|
||||
// Empty segments are dropped once the dots are resolved, as the router collapses them.
|
||||
request("/restapis//abc123");
|
||||
assertEquals(List.of("arn:aws:apigateway:us-east-1::/restapis/abc123"),
|
||||
builder.buildResources("apigateway", ctx, "us-east-1", ACCOUNT));
|
||||
request("/restapis/x/..//abc123");
|
||||
assertEquals(List.of("arn:aws:apigateway:us-east-1::/restapis/abc123"),
|
||||
builder.buildResources("apigateway", ctx, "us-east-1", ACCOUNT));
|
||||
request("/restapis/x//../abc123");
|
||||
assertEquals(List.of("arn:aws:apigateway:us-east-1::/restapis/x/abc123"),
|
||||
builder.buildResources("apigateway", ctx, "us-east-1", ACCOUNT));
|
||||
request("/v2/tags/arn:aws:apigateway:us-east-1::/apis/x/%2E%2E/a1b2c3");
|
||||
assertEquals(List.of("arn:aws:apigateway:us-east-1::/tags/arn%3Aaws%3Aapigateway%3Aus-east-1%3A%3A%2Fapis%2Fa1b2c3"),
|
||||
builder.buildResources("apigateway", ctx, "us-east-1", ACCOUNT));
|
||||
request("/restapis/");
|
||||
assertEquals(List.of("arn:aws:apigateway:us-east-1::/restapis"),
|
||||
builder.buildResources("apigateway", ctx, "us-east-1", ACCOUNT));
|
||||
// An HTTP or WebSocket API path's /v2 is not part of the resource it names.
|
||||
request("/v2/apis");
|
||||
assertEquals(List.of("arn:aws:apigateway:us-east-1::/apis"),
|
||||
builder.buildResources("apigateway", ctx, "us-east-1", ACCOUNT));
|
||||
request("/v2/apis/a1b2c3/stages/prod");
|
||||
assertEquals(List.of("arn:aws:apigateway:us-east-1::/apis/a1b2c3/stages/prod"),
|
||||
builder.buildResources("apigateway", ctx, "us-east-1", ACCOUNT));
|
||||
// A stage name keeps the characters it is written with, sent literally or encoded.
|
||||
request("/v2/apis/a1b2c3/stages/$default");
|
||||
assertEquals(List.of("arn:aws:apigateway:us-east-1::/apis/a1b2c3/stages/$default"),
|
||||
builder.buildResources("apigateway", ctx, "us-east-1", ACCOUNT));
|
||||
request("/v2/apis/a1b2c3/stages/%24default");
|
||||
assertEquals(List.of("arn:aws:apigateway:us-east-1::/apis/a1b2c3/stages/$default"),
|
||||
builder.buildResources("apigateway", ctx, "us-east-1", ACCOUNT));
|
||||
request("/v2domains");
|
||||
assertEquals(List.of("arn:aws:apigateway:us-east-1::/v2domains"),
|
||||
builder.buildResources("apigateway", ctx, "us-east-1", ACCOUNT));
|
||||
// A tagging route names the ARN it tags still encoded, as AWS names its Tags resource.
|
||||
request("/v2/tags/arn%3Aaws%3Aapigateway%3Aus-east-1%3A%3A%2Fapis%2Fa1b2c3");
|
||||
assertEquals(List.of("arn:aws:apigateway:us-east-1::/tags/arn%3Aaws%3Aapigateway%3Aus-east-1%3A%3A%2Fapis%2Fa1b2c3"),
|
||||
builder.buildResources("apigateway", ctx, "us-east-1", ACCOUNT));
|
||||
request("/v2/tags/arn:aws:apigateway:us-east-1::/apis/a1b2c3");
|
||||
assertEquals(List.of("arn:aws:apigateway:us-east-1::/tags/arn%3Aaws%3Aapigateway%3Aus-east-1%3A%3A%2Fapis%2Fa1b2c3"),
|
||||
builder.buildResources("apigateway", ctx, "us-east-1", ACCOUNT));
|
||||
request("/tags/arn%3aaws%3aapigateway%3aus-east-1%3a%3a%2frestapis%2fabc123");
|
||||
assertEquals(List.of("arn:aws:apigateway:us-east-1::/tags/arn%3Aaws%3Aapigateway%3Aus-east-1%3A%3A%2Frestapis%2Fabc123"),
|
||||
builder.buildResources("apigateway", ctx, "us-east-1", ACCOUNT));
|
||||
request("/restapis");
|
||||
assertEquals(List.of("arn:aws-us-gov:apigateway:us-gov-west-1::/restapis"),
|
||||
builder.buildResources("apigateway", ctx, "us-gov-west-1", ACCOUNT, "aws-us-gov"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void schedulerRoutesResolveTheScheduleInItsGroupTheGroupOrTheTaggedArn() {
|
||||
when(uriInfo.getPath()).thenReturn("/schedules/nightly");
|
||||
|
||||
@@ -135,8 +135,8 @@ CLIENTS_NOT_READ: dict[str, str] = {
|
||||
}
|
||||
|
||||
# The namespaces whose resources ResourceArnBuilder builds itself.
|
||||
HAND_BUILT = ("dsql", "dynamodb", "eks", "iam", "kinesis", "kms", "lambda", "logs", "pipes", "resource-groups",
|
||||
"s3", "scheduler", "secretsmanager", "sns", "sqs", "ssm", "sts")
|
||||
HAND_BUILT = ("apigateway", "dsql", "dynamodb", "eks", "iam", "kinesis", "kms", "lambda", "logs", "pipes",
|
||||
"resource-groups", "s3", "scheduler", "secretsmanager", "sns", "sqs", "ssm", "sts")
|
||||
|
||||
_LATER = "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint"
|
||||
_REST = "REST: its requests name their resources in the path, which RequestResources does not read yet"
|
||||
@@ -146,7 +146,6 @@ NOT_COVERED: dict[str, str] = {
|
||||
"access-analyzer": _REST,
|
||||
"account": _REST,
|
||||
"airflow": _REST,
|
||||
"apigateway": _REST,
|
||||
"app-integrations": _REST,
|
||||
"appconfig": _REST,
|
||||
"application-autoscaling": "not read yet: a scalable target's ARN ends in an id the service mints, "
|
||||
|
||||
Reference in new issue
Block a user