Skip to content

Commit d41cdc8

Browse files
committed
feat: 1. update Dockerfile 2. fix single quote issue 3. currentUser add ip 4. use old refresh token
1 parent 4aaf36f commit d41cdc8

File tree

24 files changed

+122
-126
lines changed

24 files changed

+122
-126
lines changed

deploy/docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ COPY --from=jre-build /build/jre /app
6565
ARG JAR_FILE=/openblocks-server/openblocks-server/target/openblocks-server-1.0-SNAPSHOT.jar
6666
ARG PLUGIN_JARS=/openblocks-server/openblocks-plugins/*/target/*.jar
6767

68-
RUN mkdir -p /openblocks /openblocks/plugins /var/www/openblocks
68+
RUN mkdir -p /openblocks /openblocks/plugins /var/www/openblocks /env2
6969

7070
COPY --from=build-server ${JAR_FILE} /openblocks/server.jar
7171
COPY --from=build-server ${PLUGIN_JARS} /openblocks/plugins/
@@ -87,7 +87,7 @@ COPY ./deploy/docker/templates/supervisord/* /etc/supervisor/conf.d/
8787

8888
# copy application.yml
8989
COPY ./server/openblocks-server/src/main/resources/selfhost/ce/application.yml /env/
90-
COPY ./server/openblocks-server/src/main/resources/selfhost/ce/application-selfhost.yml /env/
90+
COPY ./server/openblocks-server/src/main/resources/selfhost/ce/application-selfhost.yml /env2/
9191

9292
# Add bootstrapfile
9393
# COPY ./entrypoint.sh /

deploy/docker/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ init_configuration() {
1515
if ! [ -e "$YML_PATH" ]; then
1616
echo "yml configuration not exist"
1717
mkdir -p "$CONFIG_PATH"
18-
cp /env/application-selfhost.yml $CONFIG_PATH/
18+
cp /env2/application-selfhost.yml $CONFIG_PATH/
1919
fi
2020
}
2121

deploy/docker/templates/supervisord/backend.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[program:backend]
22
directory=/openblocks
33
# Ref -Dlog4j2.formatMsgNoLookups=true https://spring.io/blog/2021/12/10/log4j2-vulnerability-and-spring-boot
4-
command=/app/bin/java -Djava.security.egd="file:/dev/./urandom" -Dlog4j2.formatMsgNoLookups=true -Dspring.config.location="file:///openblocks-stacks/configuration/application-selfhost.yml,file:///env/application.yml" -jar /openblocks/server.jar
4+
command=/app/bin/java -Djava.security.egd="file:/dev/./urandom" -Dlog4j2.formatMsgNoLookups=true -Dspring.config.location="file:///env/application.yml,file:///openblocks-stacks/configuration/application-selfhost.yml" -jar /openblocks/server.jar
55

66
priority=15
77
autostart=true

server/openblocks-domain/src/main/java/com/openblocks/domain/user/model/Connection.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.fasterxml.jackson.annotation.JsonCreator;
1616
import com.fasterxml.jackson.annotation.JsonIgnore;
1717
import com.fasterxml.jackson.annotation.JsonProperty;
18+
import com.fasterxml.jackson.annotation.JsonProperty.Access;
1819

1920
import lombok.Builder;
2021
import lombok.Getter;
@@ -41,6 +42,7 @@ public class Connection {
4142
private Set<String> orgIds;
4243

4344
@Nullable
45+
@JsonProperty(access = Access.WRITE_ONLY)
4446
private ConnectionAuthToken authConnectionAuthToken;
4547

4648
private Map<String, Object> rawUserInfo;

server/openblocks-plugins/mongoPlugin/src/main/java/com/openblocks/plugin/mongo/commands/Aggregate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ public Aggregate(Map<String, Object> formData) {
6464
}
6565

6666
@Override
67-
public Boolean isValid() {
67+
public boolean isValid() {
6868
if (!super.isValid()) {
69-
return Boolean.FALSE;
69+
return false;
7070
}
7171

7272
if (StringUtils.isNullOrEmpty(pipeline)) {

server/openblocks-plugins/mongoPlugin/src/main/java/com/openblocks/plugin/mongo/commands/Delete.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,18 @@ public Delete(Map<String, Object> formData) {
5757
}
5858

5959
@Override
60-
public Boolean isValid() {
60+
public boolean isValid() {
6161
if (!super.isValid()) {
62-
return Boolean.FALSE;
62+
return false;
6363
}
6464

6565
if (StringUtils.isNotBlank(query)) {
66-
return Boolean.TRUE;
66+
return true;
6767
}
6868

6969
// Not adding smart defaults for query due to data impact
7070
fieldNamesWithNoConfiguration.add("Query");
71-
return Boolean.FALSE;
71+
return false;
7272
}
7373

7474
@Override

server/openblocks-plugins/mongoPlugin/src/main/java/com/openblocks/plugin/mongo/commands/Distinct.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@ public Distinct(Map<String, Object> formData) {
5050
}
5151

5252
@Override
53-
public Boolean isValid() {
53+
public boolean isValid() {
5454
if (!super.isValid()) {
55-
return Boolean.FALSE;
55+
return false;
5656
}
5757

5858
if (StringUtils.isNotBlank(key)) {
59-
return Boolean.TRUE;
59+
return true;
6060
}
6161

6262
fieldNamesWithNoConfiguration.add("Key/Field");
6363

64-
return Boolean.FALSE;
64+
return false;
6565
}
6666

6767
@Override

server/openblocks-plugins/mongoPlugin/src/main/java/com/openblocks/plugin/mongo/commands/Insert.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@ public Insert(Map<String, Object> formData) {
5151
}
5252

5353
@Override
54-
public Boolean isValid() {
54+
public boolean isValid() {
5555
if (!super.isValid()) {
56-
return Boolean.FALSE;
56+
return false;
5757
}
5858

5959
if (StringUtils.isNotBlank(documents)) {
60-
return Boolean.TRUE;
60+
return true;
6161
}
6262

6363
fieldNamesWithNoConfiguration.add("Documents");
64-
return Boolean.FALSE;
64+
return false;
6565
}
6666

6767
@Override

server/openblocks-plugins/mongoPlugin/src/main/java/com/openblocks/plugin/mongo/commands/MongoCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ public MongoCommand(Map<String, Object> formData) {
6666
timeoutMs = MapUtils.getInteger(formData, "timeout", DEFAULT_VALUE);
6767
}
6868

69-
public Boolean isValid() {
69+
public boolean isValid() {
7070
if (StringUtils.isBlank(this.collection)) {
7171
fieldNamesWithNoConfiguration.add(COLLECTION);
72-
return Boolean.FALSE;
72+
return false;
7373
}
74-
return Boolean.TRUE;
74+
return true;
7575
}
7676

7777
public Document parseCommand() {

server/openblocks-plugins/mongoPlugin/src/main/java/com/openblocks/plugin/mongo/commands/UpdateMany.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ public UpdateMany(Map<String, Object> formData) {
6464
}
6565

6666
@Override
67-
public Boolean isValid() {
67+
public boolean isValid() {
6868
if (!super.isValid()) {
69-
return Boolean.FALSE;
69+
return false;
7070
}
7171

7272
if (StringUtils.isNotBlank(query) && StringUtils.isNotBlank(update)) {
73-
return Boolean.TRUE;
73+
return true;
7474
}
7575

7676
// Not adding smart defaults for query due to data impact
@@ -81,7 +81,7 @@ public Boolean isValid() {
8181
if (StringUtils.isBlank(update)) {
8282
fieldNamesWithNoConfiguration.add("Update");
8383
}
84-
return Boolean.FALSE;
84+
return false;
8585
}
8686

8787
@Override

server/openblocks-plugins/mysqlPlugin/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
<groupId>mysql</groupId>
3434
<artifactId>mysql-connector-java</artifactId>
3535
<version>8.0.29</version>
36-
<!-- <scope>test</scope>-->
3736
</dependency>
3837
<dependency>
3938
<groupId>com.zaxxer</groupId>

server/openblocks-plugins/postgresPlugin/src/main/java/com/openblocks/plugin/postgres/PostgresExecutor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public PostgresQueryContext buildQueryExecutionContext(PostgresDatasourceConfig
7373
return PostgresQueryContext.builder()
7474
.query(postgresQueryConfig.getSql())
7575
.requestParams(requestParams)
76+
.disablePreparedStatement(datasourceConfig.isEnableTurnOffPreparedStatement() &&
77+
postgresQueryConfig.isDisablePreparedStatement())
7678
.build();
7779
}
7880

@@ -358,6 +360,8 @@ private static void bindPreparedStatement(int index, Object value, PreparedState
358360
}
359361
}
360362
case STRING -> preparedStatement.setString(index, String.valueOf(value));
363+
default -> {
364+
}
361365
}
362366
}
363367

server/openblocks-plugins/postgresPlugin/src/main/java/com/openblocks/plugin/postgres/model/PostgresDatasourceConfig.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,19 @@ public class PostgresDatasourceConfig implements DatasourceConnectionConfig {
4040
private final Long port;
4141
private final boolean usingSsl;
4242
private final boolean readonly;
43+
private final boolean enableTurnOffPreparedStatement;
4344

4445
@JsonCreator
4546
private PostgresDatasourceConfig(String database, String username, String password, String host, Long port,
46-
boolean usingSsl, boolean readonly) {
47+
boolean usingSsl, boolean readonly, boolean enableTurnOffPreparedStatement) {
4748
this.database = database;
4849
this.username = username;
4950
this.password = password;
5051
this.usingSsl = usingSsl;
5152
this.host = host;
5253
this.port = port;
5354
this.readonly = readonly;
55+
this.enableTurnOffPreparedStatement = enableTurnOffPreparedStatement;
5456
}
5557

5658
public static PostgresDatasourceConfig buildFrom(Map<String, Object> requestMap) {
@@ -77,6 +79,10 @@ public String getHost() {
7779
return StringUtils.trimToEmpty(host);
7880
}
7981

82+
public boolean isEnableTurnOffPreparedStatement() {
83+
return enableTurnOffPreparedStatement;
84+
}
85+
8086
@VisibleForTesting
8187
public PostgresDatasourceConfigBuilder toBuilder() {
8288
return builder()
@@ -86,7 +92,8 @@ public PostgresDatasourceConfigBuilder toBuilder() {
8692
.usingSsl(usingSsl)
8793
.host(host)
8894
.port(port)
89-
.readonly(readonly);
95+
.readonly(readonly)
96+
.enableTurnOffPreparedStatement(enableTurnOffPreparedStatement);
9097
}
9198

9299
@Override
@@ -101,7 +108,8 @@ public DatasourceConnectionConfig mergeWithUpdatedConfig(DatasourceConnectionCon
101108
updatedPostgresConfig.getHost(),
102109
updatedPostgresConfig.getPort(),
103110
updatedPostgresConfig.isUsingSsl(),
104-
updatedPostgresConfig.isReadonly());
111+
updatedPostgresConfig.isReadonly(),
112+
updatedPostgresConfig.isEnableTurnOffPreparedStatement());
105113
}
106114

107115
@Override

server/openblocks-sdk/src/main/resources/locale_en.properties

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## general
22
INTERNAL_SERVER_ERROR=Oops! Service is busy, please try again later.
3-
NOT_AUTHORIZED=Sorry, it appears you don't have the permission.
3+
NOT_AUTHORIZED=Sorry, it appears you don''t have the permission.
44
INVALID_PARAMETER=Invalid parameter found: {0}, please check and try again.
55
INFRA_REDIS_TIMEOUT=Connect timed out, please try again later.
66
INFRA_MONGODB_TIMEOUT=Connect timed out, please try again later.
@@ -22,7 +22,7 @@ INVALID_INVITATION_CODE=Invitation code not found.
2222
ALREADY_IN_ORGANIZATION=You are already in this workspace.
2323
INVITED_ORG_DELETED=Oops! The invited workspace has already been deleted.
2424
APPLICATION_NOT_FOUND=Application {0} cannot be found.
25-
ILLEGAL_APPLICATION_PERMISSION_ID=Sorry, it appears you don't have the permission.
25+
ILLEGAL_APPLICATION_PERMISSION_ID=Sorry, it appears you don''t have the permission.
2626
FETCH_HISTORY_SNAPSHOT_FAILURE=Failed to fetch application history snapshot, please try again later.
2727
FETCH_HISTORY_SNAPSHOT_COUNT_FAILURE=Failed to fetch the count of history snapshots of the application, please try again later.
2828
INVALID_HISTORY_SNAPSHOT=History snapshot {0} cannot be found.
@@ -57,17 +57,17 @@ EXCEED_QUERY_RESPONSE_SIZE=Sorry, it exceeds query response limit size, please c
5757
LIBRARY_QUERY_AND_ORG_NOT_MATCH=Query library does not match the workspace.
5858
LIBRARY_QUERY_NOT_FOUND=Sorry, query library has no such query, please check again.
5959
INVALID_USER_STATUS=Sorry, the user status is illegal: {0}.
60-
FOLDER_DELETE_NO_PERMISSION=Oops! It appears you don't have the permission to delete the folder.
60+
FOLDER_DELETE_NO_PERMISSION=Oops! It appears you don''t have the permission to delete the folder.
6161
FOLDER_NOT_EXIST=The folder does not exist, please check again.
6262
FOLDER_NAME_CONFLICT=Sorry, there is already a folder with the same name as the folder name you specified, please use a different name.
6363
INVALID_PARAMETER_PLZ_CHECK=Sorry, an invalid parameter was passed, please check: {0}.
6464
DATASOURCE_CONFIG_ERROR=Illegal data source configuration: data source parameter configuration error.
6565
CAS_SSO_TICKET_ERROR=orry, cas sso login exception: ticket validation error.
6666
FILE_NOT_EXIST=Invalid parameter: the file does not exist.
6767
FOLDER_NAME_EMPTY=Invalid parameter: the folder name is empty.
68-
NO_PERMISSION_TO_MOVE=Sorry, it appears you don't have the permission, moving apps or modules requires administrative privileges.
68+
NO_PERMISSION_TO_MOVE=Sorry, it appears you don''t have the permission, moving apps or modules requires administrative privileges.
6969
PERMISSION_NOT_EXIST=Invalid permission, it does not exist.
70-
NO_PERMISSION_TO_OPERATE_FOLDER=Sorry, it appears you don't have the permission to operate this folder.
70+
NO_PERMISSION_TO_OPERATE_FOLDER=Sorry, it appears you don''t have the permission to operate this folder.
7171
FILE_ORG_NOT_MATCH=Illegal Request: the file does not belong to current workspace.
7272
EXCEEDS_FILE_SIZE_LIMIT=Illegal Request: file size cannot exceed {0}.
7373
EXCEEDS_ORG_SIZE_LIMIT=Illegal Request: exceeds total workspace limit size {0}.
@@ -92,8 +92,8 @@ INVALID_USER_ID=Invalid parameter: the user ID is invalid.
9292
INVALID_USER_ROLE=Invalid parameter: the user role is invalid.
9393
PASSWORD_EMPTY=Invalid parameter: the password is empty.
9494
INSUFFICIENT_PERMISSION=Insufficient permissions: you are not in the workspace, please contact admin of this workspace.
95-
NO_PERMISSION_TO_EDIT=It appears you don't have the permission to edit, please contact the app owners {0}.
96-
NO_PERMISSION_TO_VIEW=It appears you don't have the permission to view, please contact the app owners {0}.
95+
NO_PERMISSION_TO_EDIT=It appears you don''t have the permission to edit, please contact the app owners {0}.
96+
NO_PERMISSION_TO_VIEW=It appears you don''t have the permission to view, please contact the app owners {0}.
9797
INVALID_QUERY_ID=Invalid query ID.
9898
INVALID_ES_CONFIG=Illegal elasticsearch data source configuration.
9999
INVALID_CONNECTION_STRING=Fail to parse connectionString.
@@ -122,7 +122,7 @@ DATASOURCE_TEST_TIMEOUT_ERROR=Test data source connection timed out, please chec
122122
JSON_PARSE_ERROR=Sorry, failed to parse JSON, data: {0}, exception information: {1}.
123123
SQL_IN_OPERATOR_PARSE_ERROR=Sorry, failed to parse SQL, data: {0}, please contact admin.
124124
PREPARED_STATEMENT_BIND_PARAMETERS_ERROR=PreparedStatement bind parameter error: {0}.
125-
EXCEED_MAX_QUERY_TIMEOUT=Sorry, query's maximum timeout cannot exceed {0}s.
125+
EXCEED_MAX_QUERY_TIMEOUT=Sorry, query''s maximum timeout cannot exceed {0}s.
126126
CONNECTION_ERROR=Connection error: {0}.
127127
MONGODB_COMMAND_ERROR=Illegal MongoDB query: {0}
128128
REST_API_EXECUTION_ERROR=REST API execution error: {0}.
@@ -147,7 +147,7 @@ INVALID_MONGODB_BSON_ARRAY_FORMAT=Invalid query configuration: not a valid Mongo
147147
INVALID_JSON_ARRAY_FORMAT=Invalid query configuration: not a valid JSON Array format.
148148
INVALID_JSON_FORMAT=Invalid query configuration: not a valid JSON {0}.
149149
INVALID_MONGODB_REQUEST=Invalid MongoDB request {0}.
150-
INVALID_PARAM_CONFIG_PLZ_CHECK=Invalid query configuration, please check these parameters' configuration: {0}.
150+
INVALID_PARAM_CONFIG_PLZ_CHECK=Invalid query configuration, please check these parameters'' configuration: {0}.
151151
GUI_COMMAND_TYPE_EMPTY=Sorry, the query configuration is invalid: the GUI command type is empty.
152152
INVALID_GUI_PARAM=Invalid GUI parameters.
153153
INVALID_GUI_COMMAND_TYPE=Invalid GUI command type {0}.
@@ -170,7 +170,7 @@ INVALID_PG_QUERY_CONFIG_EMPTY=PostgreSQL query configuration is empty.
170170
INVALID_PG=Failed to parse PostgreSQL query configuration.
171171
INVALID_RESTAPI=Failed to parse REST API query configuration.
172172
GET_MONGODB_STRUCTURE_ERROR=Failed to get MongoDB structure.
173-
MONGODB_URI_EMPTY=MongoDB's connection URI is empty.
173+
MONGODB_URI_EMPTY=MongoDB''s connection URI is empty.
174174
MONGODB_URI_EXTRACT_ERROR=Failed to resolve MongoDB connection URI.
175175
CONTENT_PARSE_ERROR=Fail to resolve multipart data, requiring array or object type.
176176
PS_BIND_ERROR=PreparedStatement binding exception: {0}, parameter type {1}.
@@ -212,7 +212,7 @@ AUTH_ERROR=Authentication error, please contact system administrator.
212212
NO_USER_FOUND=User not found.
213213
SYSTEM_GROUP_ALL_USER=All Users
214214
SYSTEM_GROUP_DEV=Developers
215-
USER_ORG_SUFFIX='s workspace
215+
USER_ORG_SUFFIX=''s workspace
216216
DEFAULT_REST_DATASOURCE_NAME=REST Query
217217
DEFAULT_OPENBLOCKS_DATASOURCE_NAME=Openblocks API
218218
## EVENT
@@ -243,7 +243,7 @@ EXCEED_MAX_ORG_MEMBER_COUNT=Sorry, this workspace has reached the maximum count
243243
EXCEED_MAX_GROUP_COUNT=Sorry, this workspace has reached the maximum count of groups.
244244
EXCEED_MAX_APP_COUNT=Sorry, you have reached maximum count of applications in current workspace.
245245
## PLUGIN
246-
DUPLICATE_COLUMN=Duplicated columns found: {0}, use keyword 'as' to rename duplicated columns.
246+
DUPLICATE_COLUMN=Duplicated columns found: {0}, use keyword ''as'' to rename duplicated columns.
247247
INVALID_JSON_FROM_RESPONSE=Response data is not a valid JSON, please check your Content-Type header.
248248
REACH_REDIRECT_LIMIT=Reach maximum HTTP redirects: {0}.
249249
GOOGLESHEETS_QUERY_PARAM_EMPTY=Google Sheets query parameter is empty.

server/openblocks-server/src/main/java/com/openblocks/api/application/ApplicationApiService.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474
@Slf4j
7575
public class ApplicationApiService {
7676

77+
private static final String LIBRARY_QUERY_DATASOURCE_TYPE = "libraryQuery";
78+
private static final String JS_DATASOURCE_TYPE = "js";
79+
private static final String VIEW_DATASOURCE_TYPE = "view";
80+
7781
@Autowired
7882
private ApplicationService applicationService;
7983

@@ -517,6 +521,11 @@ private Map<String, Object> doSanitizeQuery(Object query) {
517521
if (!(compType instanceof String datasourceType)) {
518522
return queryMap;
519523
}
524+
if (LIBRARY_QUERY_DATASOURCE_TYPE.equalsIgnoreCase(datasourceType) ||
525+
JS_DATASOURCE_TYPE.equalsIgnoreCase(datasourceType) ||
526+
VIEW_DATASOURCE_TYPE.equalsIgnoreCase(datasourceType)) {
527+
return queryMap;
528+
}
520529
var queryExecutor = datasourceMetaInfoService.getQueryExecutor(datasourceType);
521530
Object comp = queryMap.get("comp");
522531
if (!(comp instanceof Map<?, ?> queryConfig)) {

server/openblocks-server/src/main/java/com/openblocks/api/home/UserHomeApiService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
import reactor.core.publisher.Flux;
1212
import reactor.core.publisher.Mono;
1313

14+
import org.springframework.web.server.ServerWebExchange;
15+
1416
public interface UserHomeApiService {
1517

16-
Mono<UserProfileView> buildUserProfileView(User user);
18+
Mono<UserProfileView> buildUserProfileView(User user, ServerWebExchange exchange);
1719

1820
Mono<Boolean> markNewUserGuidanceShown(String userId);
1921

0 commit comments

Comments
 (0)