Increased default limit for webclient payload (#3718)
* Increased default limit for webclient payload
This commit is contained in:
parent
e347b61e53
commit
683176fc48
|
|
@ -8,7 +8,7 @@ server {
|
|||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name dev.appsmith.com;
|
||||
client_max_body_size 10m;
|
||||
client_max_body_size 100m;
|
||||
|
||||
ssl_certificate /etc/certificate/dev.appsmith.com.pem;
|
||||
ssl_certificate_key /etc/certificate/dev.appsmith.com-key.pem;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
package com.appsmith.external.services;
|
||||
|
||||
public interface SharedConfig {
|
||||
|
||||
int getCodecSize();
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
<dependency>
|
||||
<groupId>org.pf4j</groupId>
|
||||
<artifactId>pf4j-spring</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
<dependency>
|
||||
<groupId>org.pf4j</groupId>
|
||||
<artifactId>pf4j-spring</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
<dependency>
|
||||
<groupId>org.pf4j</groupId>
|
||||
<artifactId>pf4j-spring</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
<dependency>
|
||||
<groupId>org.pf4j</groupId>
|
||||
<artifactId>pf4j-spring</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
<dependency>
|
||||
<groupId>org.pf4j</groupId>
|
||||
<artifactId>pf4j-spring</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
<dependency>
|
||||
<groupId>org.pf4j</groupId>
|
||||
<artifactId>pf4j-spring</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
<dependency>
|
||||
<groupId>org.pf4j</groupId>
|
||||
<artifactId>pf4j-spring</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
<dependency>
|
||||
<groupId>org.pf4j</groupId>
|
||||
<artifactId>pf4j-spring</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
<dependency>
|
||||
<groupId>org.pf4j</groupId>
|
||||
<artifactId>pf4j-spring</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
<dependency>
|
||||
<groupId>org.pf4j</groupId>
|
||||
<artifactId>pf4j-spring</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
<dependency>
|
||||
<groupId>org.pf4j</groupId>
|
||||
<artifactId>pf4j-spring</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
<dependency>
|
||||
<groupId>org.pf4j</groupId>
|
||||
<artifactId>pf4j-spring</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
<dependency>
|
||||
<groupId>org.pf4j</groupId>
|
||||
<artifactId>pf4j-spring</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.external.connections;
|
|||
|
||||
import com.appsmith.external.models.AuthenticationDTO;
|
||||
import com.appsmith.external.models.OAuth2;
|
||||
import com.appsmith.external.services.SharedConfig;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
package com.external.connections;
|
||||
|
||||
import com.appsmith.external.constants.Authentication;
|
||||
import com.appsmith.external.exceptions.pluginExceptions.StaleConnectionException;
|
||||
import com.appsmith.external.models.AuthenticationDTO;
|
||||
import com.appsmith.external.models.AuthenticationResponse;
|
||||
import com.appsmith.external.models.OAuth2;
|
||||
import com.appsmith.external.models.UpdatableConnection;
|
||||
import com.appsmith.external.exceptions.pluginExceptions.StaleConnectionException;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
package com.external.connections;
|
||||
|
||||
import com.appsmith.external.constants.Authentication;
|
||||
import com.appsmith.external.exceptions.pluginExceptions.StaleConnectionException;
|
||||
import com.appsmith.external.models.AuthenticationDTO;
|
||||
import com.appsmith.external.models.AuthenticationResponse;
|
||||
import com.appsmith.external.models.OAuth2;
|
||||
import com.appsmith.external.models.UpdatableConnection;
|
||||
import com.appsmith.external.exceptions.pluginExceptions.StaleConnectionException;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import com.appsmith.external.models.Property;
|
|||
import com.appsmith.external.plugins.BasePlugin;
|
||||
import com.appsmith.external.plugins.PluginExecutor;
|
||||
import com.appsmith.external.plugins.SmartSubstitutionInterface;
|
||||
import com.appsmith.external.services.SharedConfig;
|
||||
import com.external.connections.APIConnection;
|
||||
import com.external.connections.APIConnectionFactory;
|
||||
import com.external.helpers.DatasourceValidator;
|
||||
|
|
@ -75,13 +76,6 @@ public class RestApiPlugin extends BasePlugin {
|
|||
|
||||
private static final int SMART_JSON_SUBSTITUTION_INDEX = 0;
|
||||
|
||||
// Setting max content length. This would've been coming from `spring.codec.max-in-memory-size` property if the
|
||||
// `WebClient` instance was loaded as an auto-wired bean.
|
||||
public static final ExchangeStrategies EXCHANGE_STRATEGIES = ExchangeStrategies
|
||||
.builder()
|
||||
.codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(/* 10MB */ 10 * 1024 * 1024))
|
||||
.build();
|
||||
|
||||
public RestApiPlugin(PluginWrapper wrapper) {
|
||||
super(wrapper);
|
||||
}
|
||||
|
|
@ -94,6 +88,20 @@ public class RestApiPlugin extends BasePlugin {
|
|||
private final String SESSION_SIGNATURE_KEY_KEY = "sessionSignatureKey";
|
||||
private final String SIGNATURE_HEADER_NAME = "X-APPSMITH-SIGNATURE";
|
||||
|
||||
private final SharedConfig sharedConfig;
|
||||
|
||||
// Setting max content length. This would've been coming from `spring.codec.max-in-memory-size` property if the
|
||||
// `WebClient` instance was loaded as an auto-wired bean.
|
||||
public ExchangeStrategies EXCHANGE_STRATEGIES;
|
||||
|
||||
public RestApiPluginExecutor(SharedConfig sharedConfig) {
|
||||
this.sharedConfig = sharedConfig;
|
||||
this.EXCHANGE_STRATEGIES = ExchangeStrategies
|
||||
.builder()
|
||||
.codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(sharedConfig.getCodecSize()))
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instead of using the default executeParametrized provided by pluginExecutor, this implementation affords an opportunity
|
||||
* also update the datasource and action configuration for pagination and some minor cleanup of the configuration before execution
|
||||
|
|
@ -288,7 +296,9 @@ public class RestApiPlugin extends BasePlugin {
|
|||
webClientBuilder.filter(apiConnection);
|
||||
}
|
||||
|
||||
WebClient client = webClientBuilder.exchangeStrategies(EXCHANGE_STRATEGIES).filter(logRequest()).build();
|
||||
WebClient client = webClientBuilder
|
||||
.exchangeStrategies(EXCHANGE_STRATEGIES)
|
||||
.filter(logRequest()).build();
|
||||
|
||||
// Triggering the actual REST API call
|
||||
return httpCall(client, httpMethod, uri, requestBodyAsString, 0, reqContentType)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import static org.junit.Assert.assertThrows;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class RestApiPluginTest {
|
||||
RestApiPlugin.RestApiPluginExecutor pluginExecutor = new RestApiPlugin.RestApiPluginExecutor();
|
||||
RestApiPlugin.RestApiPluginExecutor pluginExecutor = new RestApiPlugin.RestApiPluginExecutor(() -> 10 * 1024 * 1024);
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@
|
|||
<dependency>
|
||||
<groupId>org.pf4j</groupId>
|
||||
<artifactId>pf4j-spring</artifactId>
|
||||
<version>0.6.0</version>
|
||||
<version>0.7.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Appsmith dependencies -->
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package com.appsmith.server.configurations;
|
||||
|
||||
import com.appsmith.external.services.SharedConfig;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class SharedConfigImpl implements SharedConfig {
|
||||
|
||||
@Value("${appsmith.codec.max-in-memory-size:10}")
|
||||
private int CODEC_SIZE;
|
||||
|
||||
@Override
|
||||
public int getCodecSize() {
|
||||
return this.CODEC_SIZE * 1024 * 1024;
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,8 @@ server.forward-headers-strategy=NATIVE
|
|||
spring.data.mongodb.auto-index-creation=false
|
||||
|
||||
# Ensures that the size of the request object that we handle is controlled. By default it's 212KB.
|
||||
spring.codec.max-in-memory-size=5MB
|
||||
spring.codec.max-in-memory-size=100MB
|
||||
appsmith.codec.max-in-memory-size=${APPSMITH_CODEC_SIZE:100}
|
||||
|
||||
# MongoDB Application Database
|
||||
spring.data.mongodb.uri = ${APPSMITH_MONGODB_URI}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ APPSMITH_MAIL_ENABLED=false
|
|||
APPSMITH_ENCRYPTION_PASSWORD=abcd
|
||||
APPSMITH_ENCRYPTION_SALT=abcd
|
||||
|
||||
APPSMITH_CODEC_SIZE=10
|
||||
|
||||
#APPSMITH_OAUTH2_GOOGLE_CLIENT_ID=""
|
||||
#APPSMITH_OAUTH2_GOOGLE_CLIENT_SECRET=""
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user