diff --git a/.github/workflows/client-test.yml b/.github/workflows/client-test.yml index c89e1a66fe..80533f7782 100644 --- a/.github/workflows/client-test.yml +++ b/.github/workflows/client-test.yml @@ -206,7 +206,7 @@ jobs: --env APPSMITH_ENCRYPTION_PASSWORD=password \ --env APPSMITH_ENCRYPTION_SALT=salt \ --env APPSMITH_IS_SELF_HOSTED=false \ - --env APPSMITH_CLOUD_SERVICES_BASE_URL=https://release-cs.appsmith.com\ + --env APPSMITH_CLOUD_SERVICES_BASE_URL= \ --env APPSMITH_CLOUD_SERVICES_USERNAME= \ --env APPSMITH_CLOUD_SERVICES_PASSWORD= \ ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server:release @@ -221,7 +221,7 @@ jobs: --env APPSMITH_ENCRYPTION_PASSWORD=password \ --env APPSMITH_ENCRYPTION_SALT=salt \ --env APPSMITH_IS_SELF_HOSTED=false \ - --env APPSMITH_CLOUD_SERVICES_BASE_URL=https://release-cs.appsmith.com\ + --env APPSMITH_CLOUD_SERVICES_BASE_URL= \ --env APPSMITH_CLOUD_SERVICES_USERNAME= \ --env APPSMITH_CLOUD_SERVICES_PASSWORD= \ ${{ secrets.DOCKER_HUB_ORGANIZATION }}/appsmith-server:nightly diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/OAuth2.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/OAuth2.java index 732e0a24c6..3edd5eca7d 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/OAuth2.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/OAuth2.java @@ -3,6 +3,8 @@ package com.appsmith.external.models; import com.appsmith.external.annotations.documenttype.DocumentType; import com.appsmith.external.annotations.encryption.Encrypted; import com.appsmith.external.constants.Authentication; +import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginError; +import com.appsmith.external.exceptions.pluginExceptions.AppsmithPluginException; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Getter; @@ -12,7 +14,9 @@ import lombok.ToString; import org.apache.logging.log4j.util.Strings; import org.springframework.data.annotation.Transient; import org.springframework.util.StringUtils; +import reactor.core.publisher.Mono; +import java.time.Instant; import java.util.Arrays; import java.util.Set; import java.util.stream.Collectors; @@ -73,4 +77,15 @@ public class OAuth2 extends AuthenticationDTO { .collect(Collectors.toSet()); } } + + @Override + public Mono hasExpired() { + if (this.authenticationResponse == null) { + return Mono.error(new AppsmithPluginException( + AppsmithPluginError.PLUGIN_ERROR, + "Expected datasource to have valid authentication tokens at this point")); + } + + return Mono.just(authenticationResponse.expiresAt.isBefore(Instant.now().plusSeconds(60))); + } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/NewActionServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/NewActionServiceImpl.java index 4a77900821..1253696db2 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/NewActionServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/NewActionServiceImpl.java @@ -58,8 +58,6 @@ import javax.validation.Validator; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -538,11 +536,11 @@ public class NewActionServiceImpl extends BaseService validatedDatasourceMono = authenticationValidator.validateAuthentication(datasource).cache(); - Mono executionMono = validatedDatasourceMono .flatMap(datasourceContextService::getDatasourceContext) // Now that we have the context (connection details), execute the action. - .flatMap(resourceContext -> validatedDatasourceMono.flatMap(datasource1 -> { + .flatMap(resourceContext -> validatedDatasourceMono + .flatMap(datasource1 -> { return (Mono) pluginExecutor.executeParameterized( resourceContext.getConnection(), executeActionDTO, diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/AuthenticationService.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/AuthenticationService.java index d1fa19064a..5d1c416b78 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/AuthenticationService.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/AuthenticationService.java @@ -422,7 +422,11 @@ public class AuthenticationService { oAuth2.setAuthenticationResponse(authenticationResponse); oAuth2.setIsEncrypted(null); datasource.getDatasourceConfiguration().setAuthentication(oAuth2); - return datasourceService.update(datasource.getId(), datasource); + // We return the same object instead of the update value because the updates value + // will be in the encrypted form + return datasourceService + .update(datasource.getId(), datasource) + .thenReturn(datasource); }); }) .switchIfEmpty(Mono.just(datasource)) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ReleaseNotesService.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ReleaseNotesService.java index ef887b5bde..202935e5e1 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ReleaseNotesService.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ReleaseNotesService.java @@ -82,6 +82,8 @@ public class ReleaseNotesService { .flatMap(instanceId -> WebClient .create( baseUrl + "/api/v1/releases?instanceId=" + instanceId + + // isCloudHosted should be true only for our cloud instance, + // For docker images that burn the segment key with the image, the CE key will be present "&isSourceInstall=" + (isCloudHosted || StringUtils.isEmpty(segmentConfig.getCeKey())) + (StringUtils.isEmpty(repo) ? "" : ("&repo=" + repo)) ) diff --git a/app/server/appsmith-server/src/main/resources/application.properties b/app/server/appsmith-server/src/main/resources/application.properties index 867f87d1aa..1b86904aa7 100644 --- a/app/server/appsmith-server/src/main/resources/application.properties +++ b/app/server/appsmith-server/src/main/resources/application.properties @@ -66,7 +66,7 @@ admin.emails = ${APPSMITH_ADMIN_EMAILS:} emails.welcome.enabled = ${APPSMITH_EMAILS_WELCOME_ENABLED:true} # Appsmith Cloud Services -appsmith.cloud_services.base_url = ${APPSMITH_CLOUD_SERVICES_BASE_URL:} +appsmith.cloud_services.base_url = ${APPSMITH_CLOUD_SERVICES_BASE_URL:https://cs.appsmith.com} appsmith.cloud_services.username = ${APPSMITH_CLOUD_SERVICES_USERNAME:} appsmith.cloud_services.password = ${APPSMITH_CLOUD_SERVICES_PASSWORD:} github_repo = ${APPSMITH_GITHUB_REPO:} diff --git a/app/server/envs/dev.env.example b/app/server/envs/dev.env.example index e7e74b6bf4..569a50c320 100644 --- a/app/server/envs/dev.env.example +++ b/app/server/envs/dev.env.example @@ -11,6 +11,8 @@ APPSMITH_ENCRYPTION_SALT=abcd APPSMITH_CODEC_SIZE=10 +#APPSMITH_CLOUD_SERVICES_BASE_URL="https://release-cs.appsmith.com" + #APPSMITH_OAUTH2_GOOGLE_CLIENT_ID="" #APPSMITH_OAUTH2_GOOGLE_CLIENT_SECRET=""