mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
fix(cloudformation): provision AWS::ApiGateway::Authorizer and wire Method.AuthorizerId (#796)
CloudFormationResourceProvisioner had no case for AWS::ApiGateway::Authorizer so the resource fell through to the default stub and never reached ApiGatewayService. Stacks reported CREATE_COMPLETE while `get-authorizers` returned an empty list. provisionApiGatewayMethod additionally ignored AuthorizerId on the template, so CUSTOM/COGNITO_USER_POOLS methods were registered with a null authorizerId. The combined effect was a CloudFormation-managed TOKEN authorizer flow that silently behaved as `AuthorizationType: NONE`. This change adds a dedicated provisionApiGatewayAuthorizer that maps the CFN PascalCase properties (Name, Type, AuthorizerUri, IdentitySource, AuthorizerResultTtlInSeconds) onto the existing ApiGatewayService.createAuthorizer request shape, and threads AuthorizerId through provisionApiGatewayMethod so `!Ref MyAuthorizer` resolves correctly. Closes #788
This commit is contained in:
1 parent
e82c215d77
commit
02ab9dd1eb
2 files changed
+452
No files matched your search
+21
@@ -155,6 +155,7 @@ public class CloudFormationResourceProvisioner {
|
||||
case "AWS::Events::Rule" -> provisionEventBridgeRule(resource, properties, engine, region, stackName);
|
||||
case "AWS::ApiGateway::RestApi" -> provisionApiGatewayRestApi(resource, properties, engine, region, accountId, stackName);
|
||||
case "AWS::ApiGateway::Resource" -> provisionApiGatewayResource(resource, properties, engine, region);
|
||||
case "AWS::ApiGateway::Authorizer" -> provisionApiGatewayAuthorizer(resource, properties, engine, region);
|
||||
case "AWS::ApiGateway::Method" -> provisionApiGatewayMethod(resource, properties, engine, region);
|
||||
case "AWS::ApiGateway::Deployment" -> provisionApiGatewayDeployment(resource, properties, engine, region);
|
||||
case "AWS::ApiGateway::Stage" -> provisionApiGatewayStage(resource, properties, engine, region);
|
||||
@@ -1399,6 +1400,22 @@ public class CloudFormationResourceProvisioner {
|
||||
r.setPhysicalId(res.getId());
|
||||
}
|
||||
|
||||
private void provisionApiGatewayAuthorizer(StackResource r, JsonNode props, CloudFormationTemplateEngine engine,
|
||||
String region) {
|
||||
String apiId = resolveOptional(props, "RestApiId", engine);
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
req.put("name", resolveOptional(props, "Name", engine));
|
||||
req.put("type", resolveOptional(props, "Type", engine));
|
||||
req.put("authorizerUri", resolveOptional(props, "AuthorizerUri", engine));
|
||||
req.put("identitySource", resolveOptional(props, "IdentitySource", engine));
|
||||
String ttl = resolveOptional(props, "AuthorizerResultTtlInSeconds", engine);
|
||||
if (ttl != null) {
|
||||
req.put("authorizerResultTtlInSeconds", ttl);
|
||||
}
|
||||
var authorizer = apiGatewayService.createAuthorizer(region, apiId, req);
|
||||
r.setPhysicalId(authorizer.getId());
|
||||
}
|
||||
|
||||
private void provisionApiGatewayMethod(StackResource r, JsonNode props, CloudFormationTemplateEngine engine,
|
||||
String region) {
|
||||
String apiId = resolveOptional(props, "RestApiId", engine);
|
||||
@@ -1407,6 +1424,10 @@ public class CloudFormationResourceProvisioner {
|
||||
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
req.put("authorizationType", resolveOrDefault(props, "AuthorizationType", engine, "NONE"));
|
||||
String authorizerId = resolveOptional(props, "AuthorizerId", engine);
|
||||
if (authorizerId != null) {
|
||||
req.put("authorizerId", authorizerId);
|
||||
}
|
||||
|
||||
apiGatewayService.putMethod(region, apiId, resourceId, httpMethod, req);
|
||||
r.setPhysicalId(apiId + "-" + resourceId + "-" + httpMethod);
|
||||
|
||||
Reference in new issue
Block a user