diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/CloudServicesConfig.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/CloudServicesConfig.java index 71c89f21fa..28cf52700a 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/CloudServicesConfig.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/CloudServicesConfig.java @@ -11,12 +11,6 @@ import org.springframework.context.annotation.Configuration; public class CloudServicesConfig { private String baseUrl; - @Value("${appsmith.cloud_services.username}") - private String username; - - @Value("${appsmith.cloud_services.password}") - private String password; - @Value("${appsmith.cloud_services.template_upload_auth_header}") private String templateUploadAuthHeader; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/NetworkUtils.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/NetworkUtils.java index 263d78e018..052177b427 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/NetworkUtils.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/NetworkUtils.java @@ -1,7 +1,12 @@ package com.appsmith.server.helpers; +import com.appsmith.server.configurations.CloudServicesConfig; import com.appsmith.server.helpers.ce.NetworkUtilsCE; import org.springframework.stereotype.Component; @Component -public class NetworkUtils extends NetworkUtilsCE {} +public class NetworkUtils extends NetworkUtilsCE { + public NetworkUtils(CloudServicesConfig cloudServicesConfig) { + super(cloudServicesConfig); + } +} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/NetworkUtilsCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/NetworkUtilsCE.java index 5a044ea580..71b529bbe2 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/NetworkUtilsCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/NetworkUtilsCE.java @@ -1,23 +1,24 @@ package com.appsmith.server.helpers.ce; +import com.appsmith.server.configurations.CloudServicesConfig; +import com.appsmith.server.dtos.ResponseDTO; import com.appsmith.util.WebClientUtils; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import reactor.core.publisher.Mono; -import java.net.URI; import java.time.Duration; @Slf4j +@RequiredArgsConstructor public class NetworkUtilsCE { - private static final URI GET_IP_URI = URI.create("https://api64.ipify.org"); + private final CloudServicesConfig cloudServicesConfig; protected static String cachedAddress = null; protected static final String FALLBACK_IP = "unknown"; - protected NetworkUtilsCE() {} - /** * This method hits an API endpoint that returns the external IP address of this server instance. * @@ -30,12 +31,12 @@ public class NetworkUtilsCE { return WebClientUtils.create() .get() - .uri(GET_IP_URI) + .uri(cloudServicesConfig.getBaseUrl() + "/api/v1/ip") .retrieve() - .bodyToMono(String.class) + .bodyToMono(ResponseDTO.class) .map(address -> { - cachedAddress = address; - return address; + cachedAddress = (String) address.getData(); + return cachedAddress; }) .timeout(Duration.ofSeconds(60)) .onErrorResume(throwable -> { diff --git a/app/server/appsmith-server/src/main/resources/application.properties b/app/server/appsmith-server/src/main/resources/application.properties index 15e2bb96e3..563add9229 100644 --- a/app/server/appsmith-server/src/main/resources/application.properties +++ b/app/server/appsmith-server/src/main/resources/application.properties @@ -83,8 +83,6 @@ emails.welcome.enabled = ${APPSMITH_EMAILS_WELCOME_ENABLED:true} # Appsmith Cloud Services appsmith.cloud_services.base_url = ${APPSMITH_CLOUD_SERVICES_BASE_URL:} appsmith.cloud_services.signature_base_url = ${APPSMITH_CLOUD_SERVICES_SIGNATURE_BASE_URL:} -appsmith.cloud_services.username = ${APPSMITH_CLOUD_SERVICES_USERNAME:} -appsmith.cloud_services.password = ${APPSMITH_CLOUD_SERVICES_PASSWORD:} appsmith.cloud_services.template_upload_auth_header = ${APPSMITH_CLOUD_SERVICES_TEMPLATE_UPLOAD_AUTH:} github_repo = ${APPSMITH_GITHUB_REPO:} diff --git a/deploy/docker/fs/opt/appsmith/entrypoint.sh b/deploy/docker/fs/opt/appsmith/entrypoint.sh index 3f30e7a522..e736883fa8 100644 --- a/deploy/docker/fs/opt/appsmith/entrypoint.sh +++ b/deploy/docker/fs/opt/appsmith/entrypoint.sh @@ -15,7 +15,7 @@ mkdir -pv "$SUPERVISORD_CONF_TARGET" "$WWW_PATH" # As we want derived props alongwith the ip address we are sharing the ip address in separate keys # https://help.mixpanel.com/hc/en-us/articles/360001355266-Event-Properties if [[ -n ${APPSMITH_SEGMENT_CE_KEY-} ]]; then - ip="$(curl -sS https://api64.ipify.org || echo unknown)" + ip="$(set -o pipefail; curl -sS https://cs.appsmith.com/api/v1/ip | grep -Eo '\d+(\.\d+){3}' || echo "unknown")" curl \ --user "$APPSMITH_SEGMENT_CE_KEY:" \ --header 'Content-Type: application/json' \