Skip to content

Commit

Permalink
Merge branch 'main' into customSelect-forwardRef-warning
Browse files Browse the repository at this point in the history
  • Loading branch information
FalkWolsky authored Aug 20, 2023
2 parents 8fafb25 + 0784aba commit a87ca33
Show file tree
Hide file tree
Showing 39 changed files with 382 additions and 153 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export const themeTemplateList = [
borderRadius: "4px",
chart: JSON.stringify(ChartTheme, null, 2),
gridColumns: "24", //Added By Aqib Mirza
margin: "3px",
padding: "3px",
},
},
{
Expand All @@ -45,6 +47,8 @@ export const themeTemplateList = [
borderRadius: "4px",
chart: JSON.stringify(ChartYellowTheme, null, 2),
gridColumns: "24", //Added By Aqib Mirza
margin: "3px",
padding: "3px",
},
},
{
Expand All @@ -60,6 +64,8 @@ export const themeTemplateList = [
borderRadius: "4px",
chart: JSON.stringify(ChartGreenTheme, null, 2),
gridColumns: "24", //Added By Aqib Mirza
margin: "3px",
padding: "3px",
},
},
];
4 changes: 4 additions & 0 deletions deploy/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Image can be configured by setting environment variables.
| `ENCRYPTION_SALT` | Salt used for encrypting password | `lowcoder.org` |
| `CORS_ALLOWED_DOMAINS` | CORS allowed domains | `*` |
| `LOWCODER_MAX_REQUEST_SIZE` | Lowcoder max request size | `20m` |
| `LOWCODER_MAX_QUERY_TIMEOUT` | Lowcoder max query timeout (in seconds) | `120` |
| `LOWCODER_API_SERVICE_URL` | Lowcoder API service URL | `http://localhost:8080` |
| `LOWCODER_NODE_SERVICE_URL` | Lowcoder Node service (js executor) URL | `http://localhost:6060` |
| `DEFAULT_ORGS_PER_USER` | Default maximum organizations per user | `100` |
Expand Down Expand Up @@ -77,6 +78,8 @@ Image can be configured by setting environment variables.
| `DEFAULT_ORG_GROUP_COUNT` | Default maximum groups per organization | `100` |
| `DEFAULT_ORG_APP_COUNT` | Default maximum applications per organization | `1000` |
| `DEFAULT_DEVELOPER_COUNT` | Default maximum developers | `100` |
| `LOWCODER_MAX_QUERY_TIMEOUT` | Lowcoder max query timeout (in seconds) | `120` |
| `LOWCODER_MAX_REQUEST_SIZE` | Lowcoder max request size | `20m` |



Expand Down Expand Up @@ -122,6 +125,7 @@ Image can be configured by setting environment variables.
| --------------------------------| --------------------------------------------------------------------| ------------------------------------------------------- |
| `PUID` | ID of user running services. It will own all created logs and data. | `9001` |
| `PGID` | ID of group of the user running services. | `9001` |
| `LOWCODER_MAX_QUERY_TIMEOUT` | Lowcoder max query timeout (in seconds) | `120` |
| `LOWCODER_MAX_REQUEST_SIZE` | Lowcoder max request size | `20m` |
| `LOWCODER_API_SERVICE_URL` | Lowcoder API service URL | `http://localhost:8080` |
| `LOWCODER_NODE_SERVICE_URL` | Lowcoder Node service (js executor) URL | `http://localhost:6060` |
Expand Down
2 changes: 2 additions & 0 deletions deploy/docker/docker-compose-multi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ services:
MONGODB_URL: "mongodb://lowcoder:secret123@mongodb/lowcoder?authSource=admin"
REDIS_URL: "redis://redis:6379"
LOWCODER_NODE_SERVICE_URL: "http://lowcoder-node-service:6060"
LOWCODER_MAX_QUERY_TIMEOUT: 120
ENABLE_USER_SIGN_UP: "true"
ENCRYPTION_PASSWORD: "lowcoder.org"
ENCRYPTION_SALT: "lowcoder.org"
Expand Down Expand Up @@ -76,6 +77,7 @@ services:
PUID: "9001"
PGID: "9001"
LOWCODER_MAX_REQUEST_SIZE: 20m
LOWCODER_MAX_QUERY_TIMEOUT: 120
LOWCODER_API_SERVICE_URL: "http://lowcoder-api-service:8080"
LOWCODER_NODE_SERVICE_URL: "http://lowcoder-node-service:6060"
restart: unless-stopped
Expand Down
1 change: 1 addition & 0 deletions deploy/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ services:
LOWCODER_NODE_SERVICE_URL: "http://localhost:6060"
# frontend parameters
LOWCODER_MAX_REQUEST_SIZE: 20m
LOWCODER_MAX_QUERY_TIMEOUT: 120
volumes:
- ./lowcoder-stacks:/lowcoder-stacks
restart: unless-stopped
Expand Down
1 change: 1 addition & 0 deletions deploy/docker/frontend/01-update-nginx-conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ else
ln -s /etc/nginx/nginx-http.conf /etc/nginx/nginx.conf
fi;

sed -i "s@__LOWCODER_MAX_QUERY_TIMEOUT__@${LOWCODER_MAX_QUERY_TIMEOUT:=120}@" /etc/nginx/nginx.conf
sed -i "s@__LOWCODER_MAX_REQUEST_SIZE__@${LOWCODER_MAX_REQUEST_SIZE:=20m}@" /etc/nginx/nginx.conf
sed -i "s@__LOWCODER_API_SERVICE_URL__@${LOWCODER_API_SERVICE_URL:=http://localhost:8080}@" /etc/nginx/nginx.conf
sed -i "s@__LOWCODER_NODE_SERVICE_URL__@${LOWCODER_NODE_SERVICE_URL:=http://localhost:6060}@" /etc/nginx/nginx.conf
Expand Down
3 changes: 3 additions & 0 deletions deploy/docker/frontend/nginx-http.conf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ http {
listen 3000 default_server;
root /lowcoder/client;

proxy_connect_timeout __LOWCODER_MAX_QUERY_TIMEOUT__;
proxy_send_timeout __LOWCODER_MAX_QUERY_TIMEOUT__;
proxy_read_timeout __LOWCODER_MAX_QUERY_TIMEOUT__;

location / {
try_files $uri /index.html;
Expand Down
4 changes: 4 additions & 0 deletions deploy/docker/frontend/nginx-https.conf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ http {
include /etc/nginx/ssl-certificate.conf;
include /etc/nginx/ssl-params.conf;

proxy_connect_timeout __LOWCODER_MAX_QUERY_TIMEOUT__;
proxy_send_timeout __LOWCODER_MAX_QUERY_TIMEOUT__;
proxy_read_timeout __LOWCODER_MAX_QUERY_TIMEOUT__;

location / {
try_files $uri /index.html;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public interface AuthenticationService {

EmailAuthConfig DEFAULT_AUTH_CONFIG = new EmailAuthConfig(AuthSourceConstants.EMAIL, true, true);

Mono<FindAuthConfig> findAuthConfigByAuthId(String authId);
Mono<FindAuthConfig> findAuthConfigByAuthId(String orgId, String authId);

Mono<FindAuthConfig> findAuthConfigBySource(String source);
Mono<FindAuthConfig> findAuthConfigBySource(String orgId, String source);

Flux<FindAuthConfig> findAllAuthConfigs(boolean enableOnly);
Flux<FindAuthConfig> findAllAuthConfigs(String orgId, boolean enableOnly);
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
package org.lowcoder.domain.authentication;

import static org.lowcoder.sdk.exception.BizError.LOG_IN_SOURCE_NOT_SUPPORTED;
import static org.lowcoder.sdk.util.ExceptionUtils.ofError;

import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;

import lombok.extern.slf4j.Slf4j;
import org.lowcoder.domain.organization.service.OrganizationService;
import org.lowcoder.sdk.auth.AbstractAuthConfig;
import org.lowcoder.sdk.config.AuthProperties;
import org.lowcoder.sdk.config.CommonConfig;
import org.lowcoder.sdk.constants.WorkspaceMode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import lombok.extern.slf4j.Slf4j;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;

import static org.lowcoder.sdk.exception.BizError.LOG_IN_SOURCE_NOT_SUPPORTED;
import static org.lowcoder.sdk.util.ExceptionUtils.ofError;

@Slf4j
@Service
public class AuthenticationServiceImpl implements AuthenticationService {
Expand All @@ -31,35 +30,35 @@ public class AuthenticationServiceImpl implements AuthenticationService {
private AuthProperties authProperties;

@Override
public Mono<FindAuthConfig> findAuthConfigByAuthId(String authId) {
return findAuthConfig(abstractAuthConfig -> Objects.equals(authId, abstractAuthConfig.getId()));
public Mono<FindAuthConfig> findAuthConfigByAuthId(String orgId, String authId) {
return findAuthConfig(orgId, abstractAuthConfig -> Objects.equals(authId, abstractAuthConfig.getId()));
}

@Override
@Deprecated
public Mono<FindAuthConfig> findAuthConfigBySource(String source) {
return findAuthConfig(abstractAuthConfig -> Objects.equals(source, abstractAuthConfig.getSource()));
public Mono<FindAuthConfig> findAuthConfigBySource(String orgId, String source) {
return findAuthConfig(orgId, abstractAuthConfig -> Objects.equals(source, abstractAuthConfig.getSource()));
}

private Mono<FindAuthConfig> findAuthConfig(Function<AbstractAuthConfig, Boolean> condition) {
return findAllAuthConfigs(true)
private Mono<FindAuthConfig> findAuthConfig(String orgId, Function<AbstractAuthConfig, Boolean> condition) {
return findAllAuthConfigs(orgId,true)
.filter(findAuthConfig -> condition.apply(findAuthConfig.authConfig()))
.next()
.switchIfEmpty(ofError(LOG_IN_SOURCE_NOT_SUPPORTED, "LOG_IN_SOURCE_NOT_SUPPORTED"));
}

@Override
public Flux<FindAuthConfig> findAllAuthConfigs(boolean enableOnly) {
public Flux<FindAuthConfig> findAllAuthConfigs(String orgId, boolean enableOnly) {
return findAllAuthConfigsByDomain()
.switchIfEmpty(findAllAuthConfigsForEnterpriseMode())
.switchIfEmpty(findAllAuthConfigsForSaasMode())
.switchIfEmpty(findAllAuthConfigsForSaasMode(orgId))
.filter(findAuthConfig -> {
if (enableOnly) {
return findAuthConfig.authConfig().isEnable();
}
return true;
})
.defaultIfEmpty(new FindAuthConfig(DEFAULT_AUTH_CONFIG, null));
.concatWithValues(new FindAuthConfig(DEFAULT_AUTH_CONFIG, null));
}

private Flux<FindAuthConfig> findAllAuthConfigsByDomain() {
Expand All @@ -85,10 +84,20 @@ protected Flux<FindAuthConfig> findAllAuthConfigsForEnterpriseMode() {
);
}

private Flux<FindAuthConfig> findAllAuthConfigsForSaasMode() {
private Flux<FindAuthConfig> findAllAuthConfigsForSaasMode(String orgId) {
if (commonConfig.getWorkspace().getMode() == WorkspaceMode.SAAS) {
return Flux.fromIterable(authProperties.getAuthConfigs())
.map(abstractAuthConfig -> new FindAuthConfig(abstractAuthConfig, null));

// Get the auth configs for the current org
if(orgId != null) {
return organizationService.getById(orgId)
.flatMapIterable(organization ->
organization.getAuthConfigs()
.stream()
.map(abstractAuthConfig -> new FindAuthConfig(abstractAuthConfig, organization))
.collect(Collectors.toList())
);
}

}
return Flux.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.lowcoder.domain.plugin.client.DatasourcePluginClient;
import org.lowcoder.domain.plugin.service.DatasourceMetaInfoService;
import org.lowcoder.domain.query.util.QueryTimeoutUtils;
import org.lowcoder.sdk.config.CommonConfig;
import org.lowcoder.sdk.exception.BizException;
import org.lowcoder.sdk.exception.PluginException;
import org.lowcoder.sdk.models.QueryExecutionResult;
Expand All @@ -40,10 +41,14 @@ public class QueryExecutionService {
@Autowired
private DatasourcePluginClient datasourcePluginClient;

@Autowired
private CommonConfig common;

public Mono<QueryExecutionResult> executeQuery(Datasource datasource, Map<String, Object> queryConfig, Map<String, Object> requestParams,
String timeoutStr, QueryVisitorContext queryVisitorContext) {

int timeoutMs = QueryTimeoutUtils.parseQueryTimeoutMs(timeoutStr, requestParams);
int timeoutMs = QueryTimeoutUtils.parseQueryTimeoutMs(timeoutStr, requestParams, common.getMaxQueryTimeout());
queryConfig.putIfAbsent("timeoutMs", timeoutMs);

return Mono.defer(() -> {
if (datasourceMetaInfoService.isJsDatasourcePlugin(datasource.getType())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
public final class QueryTimeoutUtils {

private static final int DEFAULT_QUERY_TIMEOUT_MILLIS = 10000;
private static final int MAX_QUERY_TIMEOUT_SECONDS = 120;

public static int parseQueryTimeoutMs(String timeoutStr, Map<String, Object> paramMap) {
return parseQueryTimeoutMs(renderMustacheString(timeoutStr, paramMap));
public static int parseQueryTimeoutMs(String timeoutStr, Map<String, Object> paramMap, int maxQueryTimeout) {
return parseQueryTimeoutMs(renderMustacheString(timeoutStr, paramMap), maxQueryTimeout);
}

@VisibleForTesting
public static int parseQueryTimeoutMs(String timeoutStr) {
public static int parseQueryTimeoutMs(String timeoutStr, int maxQueryTimeout) {
if (StringUtils.isBlank(timeoutStr)) {
return DEFAULT_QUERY_TIMEOUT_MILLIS;
}
Expand All @@ -44,10 +43,10 @@ public static int parseQueryTimeoutMs(String timeoutStr) {
if (value < 0) {
throw new PluginException(QUERY_ARGUMENT_ERROR, "INVALID_TIMEOUT_SETTING", timeoutStr);
}

int millis = convertToMs(value, unit);
if (millis > Duration.ofSeconds(MAX_QUERY_TIMEOUT_SECONDS).toMillis()) {
throw new PluginException(EXCEED_MAX_QUERY_TIMEOUT, "EXCEED_MAX_QUERY_TIMEOUT", MAX_QUERY_TIMEOUT_SECONDS);
if (millis > Duration.ofSeconds(maxQueryTimeout).toMillis()) {
throw new PluginException(EXCEED_MAX_QUERY_TIMEOUT, "EXCEED_MAX_QUERY_TIMEOUT", maxQueryTimeout);
}

return millis;
Expand Down
Loading

0 comments on commit a87ca33

Please sign in to comment.