Skip to content

Dev -> Main (release preview) #621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 78 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
3c13c27
remove unused npm modules
raheeliftikhar5 Dec 20, 2023
09b2e2a
upgrade mermaid
raheeliftikhar5 Dec 20, 2023
f6a0416
removed @testing-library/user-event
raheeliftikhar5 Dec 20, 2023
df577d1
upgrade axios
raheeliftikhar5 Dec 20, 2023
b73df0b
upgrade codemirror
raheeliftikhar5 Dec 20, 2023
e0b7c17
remove @testing-library/react
raheeliftikhar5 Dec 21, 2023
c975e53
fix tests
raheeliftikhar5 Dec 21, 2023
ea12bc5
upgrade react, react-dom, @types/react, @types/react-dom and fixes
raheeliftikhar5 Dec 27, 2023
b4a9873
Merge pull request #593 from raheeliftikhar5/remove-unused-modules
FalkWolsky Dec 27, 2023
54786b8
publish comps workflow
raheeliftikhar5 Dec 28, 2023
ae43e5f
upgrade styles-components dependency
raheeliftikhar5 Dec 29, 2023
1cd00c2
Add Select (dropdown) column type to tables
jreyesr Dec 31, 2023
1e03ad2
updates after styled-compoents upgrade + fixing unit tests
raheeliftikhar5 Jan 1, 2024
c3bca96
Rework to finalize oauth(inherit from login) for rest api datasource
aq-ikhwa-tech Jan 1, 2024
6469516
Add handling for oauth(inherit from login) for rest api datasource
aq-ikhwa-tech Jan 1, 2024
27f45f7
fix: remove unnecessary check
aq-ikhwa-tech Jan 1, 2024
e32669c
Merge branch 'dev' into add-auth-handling-to-rest-api-datasource
aq-ikhwa-tech Jan 1, 2024
33e9b9a
Merge pull request #611 from lowcoder-org/add-auth-handling-to-rest-a…
FalkWolsky Jan 2, 2024
6ed2520
Add oauth(inherit from login) handling for graphql datasource
aq-ikhwa-tech Jan 2, 2024
61d548e
fixed video end bug
freddysundowner Jan 3, 2024
c990411
Merge pull request #612 from lowcoder-org/add-oauth-handling-to-graphql
FalkWolsky Jan 3, 2024
83d254e
Enabling selection of OAuth Token in FE
Jan 3, 2024
818cb5d
Fix auth provider attributes matching to lc attributes
aq-ikhwa-tech Jan 3, 2024
38b992b
Merge branch 'dev' into fix-oauth-provider-attributes-mapping
aq-ikhwa-tech Jan 3, 2024
2eddc01
Merge pull request #614 from lowcoder-org/fix-oauth-provider-attribut…
FalkWolsky Jan 3, 2024
9aaf4b8
Removing Typedoc
Jan 3, 2024
57b6120
OAuth impersonation for GraphQL
Jan 3, 2024
3381113
unit test fixes
raheeliftikhar5 Jan 4, 2024
ab73917
fixed unit tests
raheeliftikhar5 Jan 4, 2024
c4f898a
test workflow
raheeliftikhar5 Jan 4, 2024
796da3c
test workflow
raheeliftikhar5 Jan 4, 2024
52c9ceb
test workflow
raheeliftikhar5 Jan 4, 2024
5f060af
test workflow
raheeliftikhar5 Jan 4, 2024
26918a7
test workflow
raheeliftikhar5 Jan 4, 2024
b4c0c16
test workflow
raheeliftikhar5 Jan 4, 2024
86ece8e
test workflow
raheeliftikhar5 Jan 4, 2024
96751cd
test workflow
raheeliftikhar5 Jan 4, 2024
1814ff6
test workflow
raheeliftikhar5 Jan 4, 2024
763b6f1
test workflow
raheeliftikhar5 Jan 4, 2024
a987f29
test workflow
raheeliftikhar5 Jan 4, 2024
893d9fd
test workflow
raheeliftikhar5 Jan 4, 2024
7f73699
test workflow
raheeliftikhar5 Jan 4, 2024
b87c556
test workflow
raheeliftikhar5 Jan 5, 2024
7f8e816
test workflow
raheeliftikhar5 Jan 5, 2024
1e702b2
test workflow
raheeliftikhar5 Jan 5, 2024
79ae92d
test workflow
raheeliftikhar5 Jan 5, 2024
8252f7e
test workflow
raheeliftikhar5 Jan 5, 2024
85feb40
test workflow
raheeliftikhar5 Jan 5, 2024
45d7cce
publish lowcoder-comps workflow
raheeliftikhar5 Jan 5, 2024
61f6c23
test lowcoder-cli pipeline
raheeliftikhar5 Jan 5, 2024
a9abad1
test lowcoder-cli pipeline
raheeliftikhar5 Jan 5, 2024
1aa6c19
test lowcoder-cli pipeline
raheeliftikhar5 Jan 5, 2024
954497f
test lowcoder-cli pipeline
raheeliftikhar5 Jan 5, 2024
74d17a7
test lowcoder-cli pipeline
raheeliftikhar5 Jan 5, 2024
41470f0
test lowcoder-cli pipeline
raheeliftikhar5 Jan 5, 2024
a160f0b
test lowcoder-cli pipeline
raheeliftikhar5 Jan 5, 2024
e90e3b3
publish lowcoder-cli workflow
raheeliftikhar5 Jan 5, 2024
92b6de6
test lowcoder-core pipeline
raheeliftikhar5 Jan 5, 2024
3a444fa
test lowcoder-core pipeline
raheeliftikhar5 Jan 5, 2024
04b61f2
publish lowcoder-core workflow
raheeliftikhar5 Jan 5, 2024
c592c10
publish lowcoder-core workflow
raheeliftikhar5 Jan 5, 2024
4344485
test lowcoder-sdk pipeline
raheeliftikhar5 Jan 5, 2024
b988fe1
test lowcoder-sdk pipeline
raheeliftikhar5 Jan 5, 2024
520b626
publish lowcoder-sdk workflow
raheeliftikhar5 Jan 5, 2024
3fd234d
branch and access token update
raheeliftikhar5 Jan 5, 2024
2416789
Merge pull request #617 from raheeliftikhar5/publish-comps-workflow
FalkWolsky Jan 5, 2024
ab6d195
Regenerate Columns in Table Fix
Jan 6, 2024
c86afa3
Update Lowcoder CLI Version
Jan 6, 2024
ef96a58
Fix the fix in Lowcoder Design - was a mistake
Jan 6, 2024
031bc86
Fix readme location in Lowcoder CLI
Jan 6, 2024
3cfd977
Update Demo Plugin Sources
Jan 6, 2024
e410d95
Update Demo Plugin Sources - fix package
Jan 6, 2024
bdc2385
Update Demo Plugin Sources - fix readme
Jan 6, 2024
4dbd74d
Update Lowcoder Readme to name our new Sponsor
Jan 6, 2024
8f6ea6f
Merge branch 'dev' into feat/issue-412
FalkWolsky Jan 8, 2024
5692cc6
Merge pull request #602 from jreyesr/feat/issue-412
FalkWolsky Jan 8, 2024
0858b4f
Merge branch 'dev' into agora-integrationn
FalkWolsky Jan 9, 2024
6002540
Merge pull request #620 from lowcoder-org/agora-integrationn
FalkWolsky Jan 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.lowcoder.plugin.graphql;

import static com.google.common.base.MoreObjects.firstNonNull;
import static org.apache.commons.collections4.MapUtils.emptyIfNull;
import static org.apache.commons.lang3.StringUtils.firstNonBlank;
import static org.apache.commons.lang3.StringUtils.trimToEmpty;
import static org.lowcoder.plugin.graphql.GraphQLError.GRAPHQL_EXECUTION_ERROR;
Expand All @@ -10,6 +11,8 @@
import static org.lowcoder.sdk.exception.PluginCommonError.QUERY_EXECUTION_ERROR;
import static org.lowcoder.sdk.exception.PluginCommonError.QUERY_EXECUTION_TIMEOUT;
import static org.lowcoder.sdk.plugin.restapi.auth.RestApiAuthType.DIGEST_AUTH;
import static org.lowcoder.sdk.plugin.restapi.auth.RestApiAuthType.OAUTH2_INHERIT_FROM_LOGIN;
import static org.lowcoder.sdk.util.ExceptionUtils.propagateError;
import static org.lowcoder.sdk.util.JsonUtils.readTree;
import static org.lowcoder.sdk.util.JsonUtils.toJsonThrows;
import static org.lowcoder.sdk.util.MustacheHelper.renderMustacheString;
Expand All @@ -30,6 +33,8 @@

import javax.annotation.Nullable;

import com.google.common.collect.ImmutableMap;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.lowcoder.plugin.graphql.constants.ResponseDataType;
Expand Down Expand Up @@ -83,6 +88,8 @@
public class GraphQLExecutor implements QueryExecutor<GraphQLDatasourceConfig, Object, GraphQLQueryExecutionContext> {
private static final String RESPONSE_DATA_TYPE = "X-LOWCODER-RESPONSE-DATA-TYPE";
private static final String GRAPHQL_TYPE = "application/graphql";

private static final String DEFAULT_GRAPHQL_ERROR_CODE = "GRAPHQL_EXECUTION_ERROR";
private static final int MAX_REDIRECTS = 5;
private static final Set<String> BINARY_DATA_TYPES = Set.of("application/zip",
"application/octet-stream",
Expand Down Expand Up @@ -245,53 +252,54 @@ private List<Property> buildBodyParams(List<Property> datasourceBodyFormData, Li

@Override
public Mono<QueryExecutionResult> executeQuery(Object o, GraphQLQueryExecutionContext context) {
return Mono.defer(() -> {
URI uri = RestApiUriBuilder.buildUri(context.getUrl(), new HashMap<>(), context.getUrlParams());
WebClient.Builder webClientBuilder = WebClientBuildHelper.builder()
.disallowedHosts(commonConfig.getDisallowedHosts())
.toWebClientBuilder();

Map<String, String> allHeaders = context.getHeaders();
String contentType = context.getContentType();
allHeaders.forEach(webClientBuilder::defaultHeader);

//basic auth
AuthConfig authConfig = context.getAuthConfig();
if (authConfig != null && authConfig.getType() == RestApiAuthType.BASIC_AUTH) {
webClientBuilder.defaultHeaders(AuthHelper.basicAuth((BasicAuthConfig) authConfig));
}
return Mono.defer(() -> authByOauth2InheritFromLogin(context))
.then(Mono.defer(() -> {
URI uri = RestApiUriBuilder.buildUri(context.getUrl(), new HashMap<>(), context.getUrlParams());
WebClient.Builder webClientBuilder = WebClientBuildHelper.builder()
.disallowedHosts(commonConfig.getDisallowedHosts())
.toWebClientBuilder();

Map<String, String> allHeaders = context.getHeaders();
String contentType = context.getContentType();
allHeaders.forEach(webClientBuilder::defaultHeader);

//basic auth
AuthConfig authConfig = context.getAuthConfig();
if (authConfig != null && authConfig.getType() == RestApiAuthType.BASIC_AUTH) {
webClientBuilder.defaultHeaders(AuthHelper.basicAuth((BasicAuthConfig) authConfig));
}

if (MediaType.MULTIPART_FORM_DATA_VALUE.equals(contentType)) {
webClientBuilder.filter(new BufferingFilter());
}
if (MediaType.MULTIPART_FORM_DATA_VALUE.equals(contentType)) {
webClientBuilder.filter(new BufferingFilter());
}

webClientBuilder.defaultCookies(injectCookies(context));
webClientBuilder.defaultCookies(injectCookies(context));

WebClient client = webClientBuilder
.exchangeStrategies(EXCHANGE_STRATEGIES)
.build();
if (!GRAPHQL_TYPE.equalsIgnoreCase(contentType)) {
context.setQueryBody(convertToGraphQLBody(context));
}
BodyInserter<?, ? super ClientHttpRequest> bodyInserter = buildBodyInserter(
context.isEncodeParams(),
contentType,
context.getQueryBody(),
context.getBodyParams());
return httpCall(client, context.getHttpMethod(), uri, bodyInserter, 0, authConfig, DEFAULT_HEADERS_CONSUMER)
.flatMap(clientResponse -> clientResponse.toEntity(byte[].class))
.map(this::convertToQueryExecutionResult)
.onErrorResume(error -> {
if (error instanceof TimeoutException) {
return Mono.just(QueryExecutionResult.error(QUERY_EXECUTION_TIMEOUT, "QUERY_TIMEOUT_ERROR", error));
}
if (error instanceof PluginException pluginException) {
throw pluginException;
}
return Mono.just(
QueryExecutionResult.error(GRAPHQL_EXECUTION_ERROR, "GRAPHQL_EXECUTION_ERROR", error));
});
});
WebClient client = webClientBuilder
.exchangeStrategies(EXCHANGE_STRATEGIES)
.build();
if (!GRAPHQL_TYPE.equalsIgnoreCase(contentType)) {
context.setQueryBody(convertToGraphQLBody(context));
}
BodyInserter<?, ? super ClientHttpRequest> bodyInserter = buildBodyInserter(
context.isEncodeParams(),
contentType,
context.getQueryBody(),
context.getBodyParams());
return httpCall(client, context.getHttpMethod(), uri, bodyInserter, 0, authConfig, DEFAULT_HEADERS_CONSUMER)
.flatMap(clientResponse -> clientResponse.toEntity(byte[].class))
.map(this::convertToQueryExecutionResult)
.onErrorResume(error -> {
if (error instanceof TimeoutException) {
return Mono.just(QueryExecutionResult.error(QUERY_EXECUTION_TIMEOUT, "QUERY_TIMEOUT_ERROR", error));
}
if (error instanceof PluginException pluginException) {
throw pluginException;
}
return Mono.just(
QueryExecutionResult.error(GRAPHQL_EXECUTION_ERROR, "GRAPHQL_EXECUTION_ERROR", error));
});
}));
}

private Consumer<MultiValueMap<String, String>> injectCookies(GraphQLQueryExecutionContext request) {
Expand Down Expand Up @@ -458,6 +466,39 @@ private ResponseBodyData parseResponseDataInfo(byte[] body, MediaType contentTyp
}
}

private Mono<Void> authByOauth2InheritFromLogin(GraphQLQueryExecutionContext context) {
if (context.getAuthConfig() == null || context.getAuthConfig().getType() != OAUTH2_INHERIT_FROM_LOGIN) {
return Mono.empty();
}
return context.getAuthTokenMono()
.doOnNext(properties -> {
Map<String, List<Property>> propertyMap = properties.stream()
.collect(Collectors.groupingBy(Property::getType));

List<Property> params = propertyMap.get("param");
if (CollectionUtils.isNotEmpty(params)) {
Map<String, String> paramMap = new HashMap<>(emptyIfNull(context.getUrlParams()));
for (Property param : params) {
paramMap.put(param.getKey(), param.getValue());
}
context.setUrlParams(ImmutableMap.copyOf(paramMap));
}

List<Property> headers = propertyMap.get("header");
if (CollectionUtils.isNotEmpty(headers)) {
Map<String, String> headerMap = new HashMap<>(emptyIfNull(context.getHeaders()));
for (Property header : headers) {
headerMap.put(header.getKey(), header.getValue());
}
context.setHeaders(ImmutableMap.copyOf(headerMap));
}
})
.switchIfEmpty(Mono.error(new PluginException(GRAPHQL_EXECUTION_ERROR, DEFAULT_GRAPHQL_ERROR_CODE,
"$ACCESS_TOKEN parameter missing.")))
.onErrorResume(throwable -> propagateError(GRAPHQL_EXECUTION_ERROR, DEFAULT_GRAPHQL_ERROR_CODE, throwable))
.then();
}

@Getter
@Builder
private static class ResponseBodyData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ public boolean isForwardAllCookies() {
return forwardAllCookies;
}

public boolean isOauth2InheritFromLogin() {
if (this.authConfig != null) {
return this.authConfig.getType().name().equals(RestApiAuthType.OAUTH2_INHERIT_FROM_LOGIN.name());
}
return false;
}

@Override
public DatasourceConnectionConfig mergeWithUpdatedConfig(DatasourceConnectionConfig updatedConfig) {
if (!(updatedConfig instanceof GraphQLDatasourceConfig updatedApiConfig)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.lowcoder.sdk.exception.BizError;
import org.lowcoder.sdk.models.Property;
import org.lowcoder.sdk.models.QueryExecutionResult;
import org.lowcoder.sdk.plugin.graphql.GraphQLDatasourceConfig;
import org.lowcoder.sdk.plugin.restapi.RestApiDatasourceConfig;
import org.lowcoder.sdk.plugin.restapi.auth.OAuthInheritAuthConfig;
import org.lowcoder.sdk.query.QueryVisitorContext;
Expand Down Expand Up @@ -122,7 +123,11 @@ public Mono<QueryExecutionResult> executeApplicationQuery(ServerWebExchange exch
if(datasource.getDetailConfig() instanceof RestApiDatasourceConfig restApiDatasourceConfig
&& restApiDatasourceConfig.isOauth2InheritFromLogin()) {
paramsAndHeadersInheritFromLogin = getAuthParamsAndHeadersInheritFromLogin(tuple.getT1(), ((OAuthInheritAuthConfig)restApiDatasourceConfig.getAuthConfig()).getAuthId());
}

if(datasource.getDetailConfig() instanceof GraphQLDatasourceConfig graphQLDatasourceConfig
&& graphQLDatasourceConfig.isOauth2InheritFromLogin()) {
paramsAndHeadersInheritFromLogin = getAuthParamsAndHeadersInheritFromLogin(tuple.getT1(), ((OAuthInheritAuthConfig)graphQLDatasourceConfig.getAuthConfig()).getAuthId());
}

QueryVisitorContext queryVisitorContext = new QueryVisitorContext(userId, app.getOrganizationId(), port, cookies, paramsAndHeadersInheritFromLogin, commonConfig.getDisallowedHosts());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.lowcoder.sdk.exception.PluginCommonError;
import org.lowcoder.sdk.models.Property;
import org.lowcoder.sdk.models.QueryExecutionResult;
import org.lowcoder.sdk.plugin.graphql.GraphQLDatasourceConfig;
import org.lowcoder.sdk.plugin.restapi.RestApiDatasourceConfig;
import org.lowcoder.sdk.plugin.restapi.auth.OAuthInheritAuthConfig;
import org.lowcoder.sdk.query.QueryVisitorContext;
Expand Down Expand Up @@ -310,12 +311,16 @@ public Mono<QueryExecutionResult> executeLibraryQuery(ServerWebExchange exchange


// check if oauth inherited from login and save token
if(datasource.getDetailConfig() instanceof RestApiDatasourceConfig restApiDatasourceConfig
&& restApiDatasourceConfig.isOauth2InheritFromLogin()) {
if(datasource.getDetailConfig() instanceof RestApiDatasourceConfig restApiDatasourceConfig && restApiDatasourceConfig.isOauth2InheritFromLogin()) {
paramsAndHeadersInheritFromLogin = getParamsAndHeadersInheritFromLogin
(user, ((OAuthInheritAuthConfig)restApiDatasourceConfig.getAuthConfig()).getAuthId());
}

if(datasource.getDetailConfig() instanceof GraphQLDatasourceConfig graphQLDatasourceConfig && graphQLDatasourceConfig.isOauth2InheritFromLogin()) {
paramsAndHeadersInheritFromLogin = getParamsAndHeadersInheritFromLogin
(user, ((OAuthInheritAuthConfig)graphQLDatasourceConfig.getAuthConfig()).getAuthId());
}

QueryVisitorContext queryVisitorContext = new QueryVisitorContext(userId, orgId, port, cookies, paramsAndHeadersInheritFromLogin,
commonConfig.getDisallowedHosts());
Map<String, Object> queryConfig = baseQuery.getQueryConfig();
Expand Down