Skip to content

Dev -> Main for 2.2.2 #632

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 34 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a35a815
fix: updated helm chart to reflect all recent changes
ludomikula Jan 7, 2024
085a9d0
Add forwarding of oauth token to node service
aq-ikhwa-tech Jan 8, 2024
07b1484
fix: add COMMON_WORKSPACE_MODE setting to docker-compose files and he…
ludomikula Jan 9, 2024
9cff751
added repo check + version check with published packages
raheeliftikhar5 Jan 10, 2024
701321d
testing worflows
raheeliftikhar5 Jan 10, 2024
a740ab4
testing workflows
raheeliftikhar5 Jan 10, 2024
46a61d0
testing workflows
raheeliftikhar5 Jan 10, 2024
d769c75
testing workflows
raheeliftikhar5 Jan 10, 2024
f18b34d
testing workflows
raheeliftikhar5 Jan 10, 2024
dcffcbe
workflow updates
raheeliftikhar5 Jan 10, 2024
1d71c48
Finalize handling for open api oauth inherit from login workflow
aq-ikhwa-tech Jan 10, 2024
ede2e4e
Merge branch 'dev' into add-oauth-handling-for-open-api-datasources
aq-ikhwa-tech Jan 10, 2024
e1d2094
Update test to fix node run failure
aq-ikhwa-tech Jan 10, 2024
86d0f29
fix column disappear on resize
raheeliftikhar5 Jan 11, 2024
cc9af45
remove double shadow from table toolbar popups
raheeliftikhar5 Jan 11, 2024
5a28671
show/hide column title in table
raheeliftikhar5 Jan 11, 2024
113c768
Merge pull request #624 from lowcoder-org/add-oauth-handling-for-open…
FalkWolsky Jan 11, 2024
9d81d29
Merge branch 'dev' into worflows-updates
FalkWolsky Jan 11, 2024
b20c97f
Merge pull request #626 from raheeliftikhar5/worflows-updates
FalkWolsky Jan 11, 2024
89b1acd
Merge pull request #618 from lowcoder-org/deployment_updates
FalkWolsky Jan 11, 2024
8d485a2
Table Styles update
Jan 11, 2024
4d6f8da
Margins, Header, Borders
Jan 12, 2024
2d76ceb
added step control for number type columns
raheeliftikhar5 Jan 12, 2024
6bd21e7
show links as per space available for table links type columns
raheeliftikhar5 Jan 12, 2024
342c9da
table events added for rowShrink and download
raheeliftikhar5 Jan 12, 2024
05eacdc
table events added for columnEdited and search
raheeliftikhar5 Jan 12, 2024
6fa43f1
added precision for float number columns
raheeliftikhar5 Jan 12, 2024
185b169
Merge pull request #628 from raheeliftikhar5/table-updates
FalkWolsky Jan 13, 2024
683c87e
Margins, Header, Borders 2
Jan 13, 2024
1be2fc5
Resize handles
Jan 14, 2024
f1ced9f
Merge pull request #630 from lowcoder-org/main
FalkWolsky Jan 14, 2024
7371565
Color settings
Jan 14, 2024
c59cf2d
Merge branch 'dev' into feature/table-styling
FalkWolsky Jan 14, 2024
f0db976
Merge pull request #631 from lowcoder-org/feature/table-styling
FalkWolsky Jan 14, 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
Expand Up @@ -10,6 +10,8 @@
import org.lowcoder.sdk.config.CommonConfig;
import org.lowcoder.sdk.exception.BizException;
import org.lowcoder.sdk.exception.PluginException;
import org.lowcoder.sdk.models.JsDatasourceConnectionConfig;
import org.lowcoder.sdk.models.Property;
import org.lowcoder.sdk.models.QueryExecutionResult;
import org.lowcoder.sdk.query.QueryExecutionContext;
import org.lowcoder.sdk.query.QueryVisitorContext;
Expand All @@ -18,6 +20,7 @@
import reactor.core.publisher.Mono;

import java.time.Duration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeoutException;
Expand Down Expand Up @@ -94,6 +97,26 @@ private Mono<QueryExecutionResult> executeByNodeJs(Datasource datasource, Map<St
.collect(Collectors.toList());
context.addAll(cookies);

return datasourcePluginClient.executeQuery(datasource.getType(), queryConfig, context, datasource.getDetailConfig());
// forward oauth2 access token in case of oauth2(inherit from login)

if(datasource.getDetailConfig() instanceof JsDatasourceConnectionConfig jsDatasourceConnectionConfig
&& jsDatasourceConnectionConfig.isOauth2InheritFromLogin()) {
return Mono.defer(() -> injectOauth2Token(queryVisitorContext, context))
.then(Mono.defer(() -> datasourcePluginClient.executeQuery(datasource.getType(), queryConfig, context, datasource.getDetailConfig())));
} else {
return datasourcePluginClient.executeQuery(datasource.getType(), queryConfig, context, datasource.getDetailConfig());
}


}

private Mono<Void> injectOauth2Token(QueryVisitorContext queryVisitorContext, List<Map<String, Object>> context) {
return queryVisitorContext.getAuthTokenMono()
.doOnNext(properties -> {
for (Property property : properties) {
context.add(Map.of("key" , property.getKey(), "value", property.getValue()));
}
})
.then();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.lowcoder.sdk.plugin.restapi.auth.RestApiAuthType;
import org.springframework.data.annotation.Transient;

import lombok.Getter;
Expand Down Expand Up @@ -159,6 +160,20 @@ public DatasourceConnectionConfig mergeWithUpdatedConfig(DatasourceConnectionCon
if (this.containsKey("extra") || jsDatasourceConnectionConfig.containsKey("extra")) {
newJsDatasourceConnectionConfig.putIfAbsent("extra", ObjectUtils.firstNonNull(jsDatasourceConnectionConfig.getExtra(), this.getExtra()));
}

// for oauth handling
if(this.containsKey("authConfig")) {
if(jsDatasourceConnectionConfig.containsKey("authConfig")) {
newJsDatasourceConnectionConfig.put("authConfig", jsDatasourceConnectionConfig.get("authConfig"));
} else {
// do nothing, save empty ( this will clear db )
}
} else {
if(jsDatasourceConnectionConfig.containsKey("authConfig")) {
newJsDatasourceConnectionConfig.put("authConfig", jsDatasourceConnectionConfig.get("authConfig"));
}
}

return newJsDatasourceConnectionConfig;
}

Expand Down Expand Up @@ -199,4 +214,18 @@ private DatasourceConnectionConfig doEncryptOrDecrypt(Function<String, String> e

return this;
}

public boolean isOauth2InheritFromLogin() {
if (this.get("authConfig") != null) {
return ((HashMap<String, String>)this.get("authConfig")).get("type").equals(RestApiAuthType.OAUTH2_INHERIT_FROM_LOGIN.name());
}
return false;
}

public String getAuthId() {
if(isOauth2InheritFromLogin()) {
return ((HashMap<String, String>)this.get("authConfig")).get("authId");
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.lowcoder.infra.util.TupleUtils;
import org.lowcoder.sdk.config.CommonConfig;
import org.lowcoder.sdk.exception.BizError;
import org.lowcoder.sdk.models.JsDatasourceConnectionConfig;
import org.lowcoder.sdk.models.Property;
import org.lowcoder.sdk.models.QueryExecutionResult;
import org.lowcoder.sdk.plugin.graphql.GraphQLDatasourceConfig;
Expand Down Expand Up @@ -122,12 +123,18 @@ public Mono<QueryExecutionResult> executeApplicationQuery(ServerWebExchange exch
// Check if oauth inherited from login and save token
if(datasource.getDetailConfig() instanceof RestApiDatasourceConfig restApiDatasourceConfig
&& restApiDatasourceConfig.isOauth2InheritFromLogin()) {
paramsAndHeadersInheritFromLogin = getAuthParamsAndHeadersInheritFromLogin(tuple.getT1(), ((OAuthInheritAuthConfig)restApiDatasourceConfig.getAuthConfig()).getAuthId());
paramsAndHeadersInheritFromLogin = getAuthParamsAndHeadersInheritFromLogin(tuple.getT1(), ((OAuthInheritAuthConfig)restApiDatasourceConfig.getAuthConfig()).getAuthId(), false);
}

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


if(datasource.getDetailConfig() instanceof JsDatasourceConnectionConfig jsDatasourceConnectionConfig
&& jsDatasourceConnectionConfig.isOauth2InheritFromLogin()) {
paramsAndHeadersInheritFromLogin = getAuthParamsAndHeadersInheritFromLogin(tuple.getT1(), jsDatasourceConnectionConfig.getAuthId(), true);
}

QueryVisitorContext queryVisitorContext = new QueryVisitorContext(userId, app.getOrganizationId(), port, cookies, paramsAndHeadersInheritFromLogin, commonConfig.getDisallowedHosts());
Expand Down Expand Up @@ -196,7 +203,7 @@ private Mono<BaseQuery> getBaseQueryFromLibraryQuery(ApplicationQuery query) {
.map(LibraryQueryRecord::getQuery);
}

protected Mono<List<Property>> getAuthParamsAndHeadersInheritFromLogin(User user, String authId) {
protected Mono<List<Property>> getAuthParamsAndHeadersInheritFromLogin(User user, String authId, boolean isJsQuery) {
if(authId == null) {
return Mono.empty();
}
Expand All @@ -207,7 +214,11 @@ protected Mono<List<Property>> getAuthParamsAndHeadersInheritFromLogin(User user
if(!activeConnectionOptional.isPresent() || activeConnectionOptional.get().getAuthConnectionAuthToken() == null) {
return Mono.empty();
}
return Mono.just(Collections.singletonList(new Property("Authorization","Bearer " + activeConnectionOptional.get().getAuthConnectionAuthToken().getAccessToken(),"header")));
if(isJsQuery) {
return Mono.just(Collections.singletonList(new Property("OAUTH_ACCESS_TOKEN",activeConnectionOptional.get().getAuthConnectionAuthToken().getAccessToken(),"header")));
} else {
return Mono.just(Collections.singletonList(new Property("Authorization","Bearer " + activeConnectionOptional.get().getAuthConnectionAuthToken().getAccessToken(),"header")));
}
}

protected void onNextOrError(QueryExecutionRequest queryExecutionRequest, QueryVisitorContext queryVisitorContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.lowcoder.sdk.config.CommonConfig;
import org.lowcoder.sdk.exception.BizError;
import org.lowcoder.sdk.exception.PluginCommonError;
import org.lowcoder.sdk.models.JsDatasourceConnectionConfig;
import org.lowcoder.sdk.models.Property;
import org.lowcoder.sdk.models.QueryExecutionResult;
import org.lowcoder.sdk.plugin.graphql.GraphQLDatasourceConfig;
Expand Down Expand Up @@ -263,7 +264,7 @@ public Mono<QueryExecutionResult> executeLibraryQueryFromJs(ServerWebExchange ex
Datasource datasource = tuple.getT3();
User user = tuple.getT4();
Mono<List<Property>> paramsAndHeadersInheritFromLogin = orgMember.isInvalid()
? Mono.empty() : getParamsAndHeadersInheritFromLogin(user, null);
? Mono.empty() : getParamsAndHeadersInheritFromLogin(user, null, false);

QueryVisitorContext queryVisitorContext = new QueryVisitorContext(userId, orgId, port,
exchange.getRequest().getCookies(),
Expand Down Expand Up @@ -313,12 +314,18 @@ public Mono<QueryExecutionResult> executeLibraryQuery(ServerWebExchange exchange
// check if oauth inherited from login and save token
if(datasource.getDetailConfig() instanceof RestApiDatasourceConfig restApiDatasourceConfig && restApiDatasourceConfig.isOauth2InheritFromLogin()) {
paramsAndHeadersInheritFromLogin = getParamsAndHeadersInheritFromLogin
(user, ((OAuthInheritAuthConfig)restApiDatasourceConfig.getAuthConfig()).getAuthId());
(user, ((OAuthInheritAuthConfig)restApiDatasourceConfig.getAuthConfig()).getAuthId(), false);
}

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

if(datasource.getDetailConfig() instanceof JsDatasourceConnectionConfig jsDatasourceConnectionConfig
&& jsDatasourceConnectionConfig.isOauth2InheritFromLogin()) {
paramsAndHeadersInheritFromLogin = getParamsAndHeadersInheritFromLogin
(user, jsDatasourceConnectionConfig.getAuthId(), true);
}

QueryVisitorContext queryVisitorContext = new QueryVisitorContext(userId, orgId, port, cookies, paramsAndHeadersInheritFromLogin,
Expand Down Expand Up @@ -348,7 +355,7 @@ private Mono<BaseQuery> getBaseQuery(LibraryQueryCombineId libraryQueryCombineId
.map(LibraryQueryRecord::getQuery);
}

protected Mono<List<Property>> getParamsAndHeadersInheritFromLogin(User user, String authId) {
protected Mono<List<Property>> getParamsAndHeadersInheritFromLogin(User user, String authId, boolean isJsQuery) {
if(authId == null) {
return Mono.empty();
}
Expand All @@ -359,7 +366,11 @@ protected Mono<List<Property>> getParamsAndHeadersInheritFromLogin(User user, St
if(!activeConnectionOptional.isPresent() || activeConnectionOptional.get().getAuthConnectionAuthToken() == null) {
return Mono.empty();
}
return Mono.just(Collections.singletonList(new Property("Authorization","Bearer " + activeConnectionOptional.get().getAuthConnectionAuthToken().getAccessToken(),"header")));
if(isJsQuery) {
return Mono.just(Collections.singletonList(new Property("OAUTH_ACCESS_TOKEN",activeConnectionOptional.get().getAuthConnectionAuthToken().getAccessToken(),"header")));
} else {
return Mono.just(Collections.singletonList(new Property("Authorization","Bearer " + activeConnectionOptional.get().getAuthConnectionAuthToken().getAccessToken(),"header")));
}
}

protected void onNextOrError(QueryExecutionRequest queryExecutionRequest, QueryVisitorContext queryVisitorContext, BaseQuery baseQuery,
Expand Down
2 changes: 1 addition & 1 deletion server/node-service/src/plugins/openApi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export async function runOpenApi(

try {
const { parameters, requestBody } = normalizeParams(otherActionData, operation, isOas3Spec);
const securities = extractSecurityParams(dataSourceConfig.dynamicParamsConfig, definition);
let securities = extractSecurityParams(dataSourceConfig, definition);
const response = await SwaggerClient.execute({
spec: definition,
operationId: realOperationId,
Expand Down
2 changes: 1 addition & 1 deletion server/node-service/src/plugins/openApi/util.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { extractSecurityParams, getSchemaExample, extractLevelData, parseUrl } from "./util";

test("extractSecurityParams", () => {
const params = extractSecurityParams({ "ApiKeyAuth.value": "hello", ApiKeyAuth: null }, {
const params = extractSecurityParams({"dynamicParamsConfig":{ "ApiKeyAuth.value": "hello", ApiKeyAuth: null }}, {
openapi: "3.0",
components: {
securitySchemes: {
Expand Down
15 changes: 14 additions & 1 deletion server/node-service/src/plugins/openApi/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ interface NormalizedParams {
requestBody?: any;
}

export function extractSecurityParams(config: any, spec: OpenAPI.Document) {
export function extractSecurityParams(datasourceConfig: any, spec: OpenAPI.Document) {
const config = datasourceConfig.dynamicParamsConfig;
if (!config) {
return {};
}
Expand All @@ -96,6 +97,18 @@ export function extractSecurityParams(config: any, spec: OpenAPI.Document) {
names = Object.keys(swagger2Spec.securityDefinitions || {});
}
const authorized = _.pick(authData, names);

let oauthAccessToken = datasourceConfig["OAUTH_ACCESS_TOKEN"];

if(oauthAccessToken) {
return {
authorized: {
OAUTH_ACCESS_TOKEN: { value: oauthAccessToken }
},
specSecurity: []
};
}

return { authorized, specSecurity: spec.security };
}

Expand Down
7 changes: 5 additions & 2 deletions server/node-service/src/services/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,12 @@ export async function runPluginQuery(
const queryConfig = await getQueryConfig(plugin, dataSourceConfig);
const action = await evalToValue(queryConfig, dsl, context, dataSourceConfig);

//forward cookies
// forward cookies
context.forEach(({ key, value }) => {
if (dataSourceConfig.dynamicParamsConfig && key in dataSourceConfig.dynamicParamsConfig) {
// for oauth(inherit from login) support
if(key == "OAUTH_ACCESS_TOKEN") {
dataSourceConfig["OAUTH_ACCESS_TOKEN"] = value
} else if (dataSourceConfig.dynamicParamsConfig && key in dataSourceConfig.dynamicParamsConfig) {
const valueKey = `${key}.value`;
dataSourceConfig.dynamicParamsConfig[valueKey] = value[0].value
}
Expand Down