mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(apigatewayv2): retain integration TLS config (#9354)
API Gateway V2 integrations now store TlsConfig and return it from create, update, get and list over the REST and JSON paths. An update that omits it keeps it, and a malformed value is refused before the integration changes. Closes #9337.
This commit is contained in:
1 parent
2f4b2c492a
commit
97acf496d9
5 files changed
+110
-14
No files matched your search
@@ -2879,6 +2879,12 @@ public class ApiGatewayController {
|
||||
}
|
||||
if (i.getConnectionType() != null) node.put("connectionType", i.getConnectionType());
|
||||
if (i.getConnectionId() != null) node.put("connectionId", i.getConnectionId());
|
||||
if (i.getTlsConfig() != null) {
|
||||
ObjectNode tlsConfig = node.putObject("tlsConfig");
|
||||
if (i.getTlsConfig().getServerNameToVerify() != null) {
|
||||
tlsConfig.put("serverNameToVerify", i.getTlsConfig().getServerNameToVerify());
|
||||
}
|
||||
}
|
||||
node.put("payloadFormatVersion", i.getPayloadFormatVersion());
|
||||
if (i.getCredentialsArn() != null) {
|
||||
node.put("credentialsArn", i.getCredentialsArn());
|
||||
|
||||
@@ -664,6 +664,12 @@ public class ApiGatewayV2JsonHandler {
|
||||
}
|
||||
if (i.getConnectionType() != null) node.put("ConnectionType", i.getConnectionType());
|
||||
if (i.getConnectionId() != null) node.put("ConnectionId", i.getConnectionId());
|
||||
if (i.getTlsConfig() != null) {
|
||||
ObjectNode tlsConfig = node.putObject("TlsConfig");
|
||||
if (i.getTlsConfig().getServerNameToVerify() != null) {
|
||||
tlsConfig.put("ServerNameToVerify", i.getTlsConfig().getServerNameToVerify());
|
||||
}
|
||||
}
|
||||
node.put("PayloadFormatVersion", i.getPayloadFormatVersion());
|
||||
if (i.getCredentialsArn() != null) {
|
||||
node.put("CredentialsArn", i.getCredentialsArn());
|
||||
|
||||
@@ -823,6 +823,7 @@ public class ApiGatewayV2Service {
|
||||
integration.setResponseParameters(responseParameters);
|
||||
|
||||
integration.setConnectionId((String) request.get("connectionId"));
|
||||
integration.setTlsConfig(integrationTlsConfig(request.get("tlsConfig")));
|
||||
|
||||
integrationStore.put(integrationKey(region, apiId, integration.getIntegrationId()), integration);
|
||||
return integration;
|
||||
@@ -854,6 +855,7 @@ public class ApiGatewayV2Service {
|
||||
public Integration updateIntegration(String region, String apiId, String integrationId,
|
||||
Map<String, Object> request) {
|
||||
Integration integration = getIntegration(region, apiId, integrationId);
|
||||
Integration.TlsConfig tlsConfig = integrationTlsConfig(request.get("tlsConfig"));
|
||||
Map<String, String> requestParameters = mergedParameters(integration.getRequestParameters(),
|
||||
stringParameters(request.get("requestParameters"), "RequestParameters"));
|
||||
Map<String, Map<String, String>> responseParameters = mergedResponseParameters(
|
||||
@@ -914,6 +916,9 @@ public class ApiGatewayV2Service {
|
||||
if (request.containsKey("connectionId") && request.get("connectionId") != null) {
|
||||
integration.setConnectionId((String) request.get("connectionId"));
|
||||
}
|
||||
if (request.get("tlsConfig") != null) {
|
||||
integration.setTlsConfig(tlsConfig);
|
||||
}
|
||||
|
||||
integrationStore.put(integrationKey(region, apiId, integrationId), integration);
|
||||
return integration;
|
||||
@@ -927,6 +932,20 @@ public class ApiGatewayV2Service {
|
||||
return (String) description;
|
||||
}
|
||||
|
||||
private static Integration.TlsConfig integrationTlsConfig(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (!(value instanceof Map<?, ?> tlsConfig)) {
|
||||
throw new AwsException("BadRequestException", "TlsConfig must be an object.", 400);
|
||||
}
|
||||
Object serverName = tlsConfig.get("serverNameToVerify");
|
||||
if (serverName != null && !(serverName instanceof String)) {
|
||||
throw new AwsException("BadRequestException", "ServerNameToVerify must be a string.", 400);
|
||||
}
|
||||
return new Integration.TlsConfig((String) serverName);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> T updatedValue(Map<String, Object> request, String key, T stored) {
|
||||
Object value = request.get(key);
|
||||
|
||||
@@ -23,11 +23,27 @@ public class Integration {
|
||||
private Map<String, String> requestParameters;
|
||||
private Map<String, Map<String, String>> responseParameters;
|
||||
private String connectionId;
|
||||
private TlsConfig tlsConfig;
|
||||
|
||||
private String credentialsArn;
|
||||
|
||||
public Integration() {}
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class TlsConfig {
|
||||
private String serverNameToVerify;
|
||||
|
||||
public TlsConfig() {}
|
||||
|
||||
public TlsConfig(String serverNameToVerify) {
|
||||
this.serverNameToVerify = serverNameToVerify;
|
||||
}
|
||||
|
||||
public String getServerNameToVerify() { return serverNameToVerify; }
|
||||
public void setServerNameToVerify(String serverNameToVerify) { this.serverNameToVerify = serverNameToVerify; }
|
||||
}
|
||||
|
||||
public String getCredentialsArn() { return credentialsArn; }
|
||||
public void setCredentialsArn(String credentialsArn) { this.credentialsArn = credentialsArn; }
|
||||
|
||||
@@ -49,6 +65,7 @@ public class Integration {
|
||||
this.requestParameters = src.requestParameters;
|
||||
this.responseParameters = src.responseParameters;
|
||||
this.connectionId = src.connectionId;
|
||||
this.tlsConfig = src.tlsConfig;
|
||||
}
|
||||
|
||||
public String getIntegrationId() { return integrationId; }
|
||||
@@ -95,4 +112,7 @@ public class Integration {
|
||||
|
||||
public String getConnectionId() { return connectionId; }
|
||||
public void setConnectionId(String connectionId) { this.connectionId = connectionId; }
|
||||
|
||||
public TlsConfig getTlsConfig() { return tlsConfig; }
|
||||
public void setTlsConfig(TlsConfig tlsConfig) { this.tlsConfig = tlsConfig; }
|
||||
}
|
||||
Reference in new issue
Block a user