From f0ea38dc71cafdf490f27dfb0c4cc72c2984d7e9 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Wed, 11 Sep 2024 15:31:56 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat(X-Pack):=20=E6=96=B0=E5=A2=9Eoauth2?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=20#11745?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core-frontend/src/utils/logout.ts | 8 +++++ core/core-frontend/src/views/login/index.vue | 4 ++- .../settings/XpackAuthenticationApi.java | 10 +++++++ .../api/xpack/settings/XpackOauth2Api.java | 25 ++++++++++++++++ .../request/XpackOauth2TokenRequest.java | 16 ++++++++++ .../api/xpack/settings/vo/XpackOauth2VO.java | 30 +++++++++++++++++++ .../xpack/settings/vo/XpackOauthAuthVO.java | 22 ++++++++++++++ .../xpack/settings/vo/XpackOauthTokenVO.java | 16 ++++++++++ .../io/dataease/utils/WhitelistUtils.java | 1 + 9 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/XpackOauth2Api.java create mode 100644 sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/request/XpackOauth2TokenRequest.java create mode 100644 sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/vo/XpackOauth2VO.java create mode 100644 sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/vo/XpackOauthAuthVO.java create mode 100644 sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/vo/XpackOauthTokenVO.java diff --git a/core/core-frontend/src/utils/logout.ts b/core/core-frontend/src/utils/logout.ts index 9050024717..d69b27833f 100644 --- a/core/core-frontend/src/utils/logout.ts +++ b/core/core-frontend/src/utils/logout.ts @@ -3,12 +3,20 @@ import router from '@/router' import { usePermissionStoreWithOut } from '@/store/modules/permission' import { interactiveStoreWithOut } from '@/store/modules/interactive' import { useCache } from '@/hooks/web/useCache' +import request from '@/config/axios' + const { wsCache } = useCache() const permissionStore = usePermissionStoreWithOut() const userStore = useUserStoreWithOut() const interactiveStore = interactiveStoreWithOut() export const logoutHandler = (justClean?: boolean) => { + const idToken = wsCache.get('oauth2-id-token') + if (idToken) { + request.get({ url: `/oauth2/logout/${idToken}` }).finally(() => { + wsCache.delete('oauth2-id-token') + }) + } userStore.clear() userStore.$reset() permissionStore.clear() diff --git a/core/core-frontend/src/views/login/index.vue b/core/core-frontend/src/views/login/index.vue index 03ac31f688..125ccb0d4b 100644 --- a/core/core-frontend/src/views/login/index.vue +++ b/core/core-frontend/src/views/login/index.vue @@ -16,7 +16,7 @@ import { XpackComponent } from '@/components/plugin' import { logoutHandler } from '@/utils/logout' import DeImage from '@/assets/login-desc-de.png' import elementResizeDetectorMaker from 'element-resize-detector' -import { checkPlatform, cleanPlatformFlag } from '@/utils/utils' +import { checkPlatform, cleanPlatformFlag, getQueryString } from '@/utils/utils' import xss from 'xss' const { wsCache } = useCache() const appStore = useAppStoreWithOut() @@ -253,6 +253,8 @@ onMounted(async () => { } else { preheat.value = false } + } else if (getQueryString('state')?.includes('de-oauth2-')) { + preheat.value = true } if (localStorage.getItem('DE-GATEWAY-FLAG')) { const msg = localStorage.getItem('DE-GATEWAY-FLAG') diff --git a/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/XpackAuthenticationApi.java b/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/XpackAuthenticationApi.java index 0fd39d16cc..3e7d3ece96 100644 --- a/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/XpackAuthenticationApi.java +++ b/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/XpackAuthenticationApi.java @@ -34,6 +34,9 @@ public interface XpackAuthenticationApi { @PostMapping("/save/ldap") String saveLdap(@RequestBody XpackLdapVO editor); + @PostMapping("/save/oauth2") + String saveOauth2(@RequestBody XpackOauth2VO editor); + @GetMapping("/info/oidc") XpackOidcVO oidcInfo(); @@ -44,6 +47,9 @@ public interface XpackAuthenticationApi { @GetMapping("/info/ldap") XpackLdapVO ldapInfo(); + @GetMapping("/info/oauth2") + XpackOauth2VO oauth2Info(); + @PostMapping("/validate/oidc") String validateOidc(@RequestBody XpackOidcVO editor); @@ -54,10 +60,14 @@ public interface XpackAuthenticationApi { @PostMapping("/validate/ldap") String validateLdap(@RequestBody XpackLdapVO editor); + @PostMapping("/validate/oauth2") + String validateOauth2(@RequestBody XpackOauth2VO editor); + @PostMapping("/validateId/{id}") String validate(@PathVariable("id") Long id); @Operation(summary = "查询状态") @GetMapping("/status") List status(); + } diff --git a/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/XpackOauth2Api.java b/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/XpackOauth2Api.java new file mode 100644 index 0000000000..94e6da6cb2 --- /dev/null +++ b/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/XpackOauth2Api.java @@ -0,0 +1,25 @@ +package io.dataease.api.xpack.settings; + +import com.github.xiaoymin.knife4j.annotations.ApiSupport; +import io.dataease.api.xpack.settings.request.XpackOauth2TokenRequest; +import io.dataease.api.xpack.settings.vo.XpackOauthAuthVO; +import io.dataease.api.xpack.settings.vo.XpackOauthTokenVO; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +@Tag(name = "Oauth2认证") +@ApiSupport(order = 899) +public interface XpackOauth2Api { + + @GetMapping("/auth") + XpackOauthAuthVO auth(); + + @PostMapping("/token") + XpackOauthTokenVO oauth2Token(@RequestBody XpackOauth2TokenRequest request); + + @GetMapping("/logout/{idToken}") + void logout(@PathVariable("idToken") String idToken); +} diff --git a/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/request/XpackOauth2TokenRequest.java b/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/request/XpackOauth2TokenRequest.java new file mode 100644 index 0000000000..905f962dc5 --- /dev/null +++ b/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/request/XpackOauth2TokenRequest.java @@ -0,0 +1,16 @@ +package io.dataease.api.xpack.settings.request; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class XpackOauth2TokenRequest implements Serializable { + @Serial + private static final long serialVersionUID = 489213446985742448L; + + private String code; + + private String state; +} diff --git a/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/vo/XpackOauth2VO.java b/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/vo/XpackOauth2VO.java new file mode 100644 index 0000000000..2546523ea6 --- /dev/null +++ b/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/vo/XpackOauth2VO.java @@ -0,0 +1,30 @@ +package io.dataease.api.xpack.settings.vo; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class XpackOauth2VO implements Serializable { + @Serial + private static final long serialVersionUID = 2395518228048236146L; + + private String clientId; + + private String clientSecret; + + private String authEndpoint; + + private String tokenEndpoint; + + private String userInfoEndpoint; + + private String logoutEndpoint; + + private String scope; + + private String mapping; + + private String redirectUri; +} diff --git a/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/vo/XpackOauthAuthVO.java b/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/vo/XpackOauthAuthVO.java new file mode 100644 index 0000000000..3df99239e1 --- /dev/null +++ b/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/vo/XpackOauthAuthVO.java @@ -0,0 +1,22 @@ +package io.dataease.api.xpack.settings.vo; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class XpackOauthAuthVO implements Serializable { + @Serial + private static final long serialVersionUID = -3658093847024323465L; + + private String state; + + private String clientId; + + private String redirectUri; + + private String authEndpoint; + + private String scope; +} diff --git a/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/vo/XpackOauthTokenVO.java b/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/vo/XpackOauthTokenVO.java new file mode 100644 index 0000000000..a4a792343e --- /dev/null +++ b/sdk/api/api-base/src/main/java/io/dataease/api/xpack/settings/vo/XpackOauthTokenVO.java @@ -0,0 +1,16 @@ +package io.dataease.api.xpack.settings.vo; + +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; + +@Data +public class XpackOauthTokenVO implements Serializable { + @Serial + private static final long serialVersionUID = -3594367641594329352L; + + private String token; + + private String idToken; +} diff --git a/sdk/common/src/main/java/io/dataease/utils/WhitelistUtils.java b/sdk/common/src/main/java/io/dataease/utils/WhitelistUtils.java index eca81b2c1c..d2742fafd8 100644 --- a/sdk/common/src/main/java/io/dataease/utils/WhitelistUtils.java +++ b/sdk/common/src/main/java/io/dataease/utils/WhitelistUtils.java @@ -68,6 +68,7 @@ public class WhitelistUtils { || StringUtils.startsWithAny(requestURI, "/geo/") || StringUtils.startsWithAny(requestURI, "/websocket") || StringUtils.startsWithAny(requestURI, "/map/") + || StringUtils.startsWithAny(requestURI, "/oauth2/") || StringUtils.startsWithAny(requestURI, "/typeface/download") || StringUtils.startsWithAny(requestURI, "/typeface/defaultFont") || StringUtils.startsWithAny(requestURI, "/typeface/listFont") From 95194d852f1ba4e57d70a17d0f54f8d13fb8c937 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Wed, 11 Sep 2024 15:35:04 +0800 Subject: [PATCH 2/3] =?UTF-8?q?perf(X-Pack):=20=E5=90=8C=E6=AD=A5=E5=AD=90?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- de-xpack | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/de-xpack b/de-xpack index adfb61c3ef..8ec01af68b 160000 --- a/de-xpack +++ b/de-xpack @@ -1 +1 @@ -Subproject commit adfb61c3ef5171563fdcd7db101ff2aabc5556dd +Subproject commit 8ec01af68b38419a065d57f80f915b903ddc00bb From eb3ea6751b051ea15de48db65320cb10fce40be7 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Wed, 11 Sep 2024 16:19:47 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E9=99=90=E5=88=B6=E6=9D=A1=E6=95=B0?= =?UTF-8?q?=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exportCenter/manage/ExportCenterManage.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/exportCenter/manage/ExportCenterManage.java b/core/core-backend/src/main/java/io/dataease/exportCenter/manage/ExportCenterManage.java index c66a8e0d0e..bd24f73f09 100644 --- a/core/core-backend/src/main/java/io/dataease/exportCenter/manage/ExportCenterManage.java +++ b/core/core-backend/src/main/java/io/dataease/exportCenter/manage/ExportCenterManage.java @@ -94,7 +94,7 @@ public class ExportCenterManage { @Value("${dataease.export.max.size:10}") private int max; - @Value("${dataease.export.dataset.limit:100000}") + @Value("${dataease.export.dataset.limit:20}") private int limit; private final static String DATA_URL_TITLE = "data:image/jpeg;base64,"; private static final String exportData_path = "/opt/dataease2.0/data/exportData/"; @@ -153,7 +153,7 @@ public class ExportCenterManage { } private Long getExportLimit() { - return Math.min(f2CLicLimitedManage.checkDatasetLimit(),limit); + return Math.min(f2CLicLimitedManage.checkDatasetLimit(), limit); } public void download(String id, HttpServletResponse response) throws Exception { @@ -395,7 +395,7 @@ public class ExportCenterManage { } if (StringUtils.isNotEmpty(request.getExpressionTree())) { Gson gson = new Gson(); - DatasetRowPermissionsTreeObj datasetRowPermissionsTreeObj =JsonUtil.parseObject(request.getExpressionTree(), DatasetRowPermissionsTreeObj.class); + DatasetRowPermissionsTreeObj datasetRowPermissionsTreeObj = JsonUtil.parseObject(request.getExpressionTree(), DatasetRowPermissionsTreeObj.class); permissionManage.getField(datasetRowPermissionsTreeObj); DataSetRowPermissionsTreeDTO dataSetRowPermissionsTreeDTO = new DataSetRowPermissionsTreeDTO(); dataSetRowPermissionsTreeDTO.setTree(datasetRowPermissionsTreeObj); @@ -421,13 +421,15 @@ public class ExportCenterManage { totalCount = totalCount > curLimit ? curLimit : totalCount; Long totalPage = (totalCount / extractPageSize) + (totalCount % extractPageSize > 0 ? 1 : 0); - Workbook wb = new SXSSFWorkbook(); FileOutputStream fileOutputStream = new FileOutputStream(dataPath + "/" + request.getFilename() + ".xlsx"); Sheet detailsSheet = wb.createSheet("数据"); for (Integer p = 0; p < totalPage; p++) { String querySQL = SQLProvider.createQuerySQLWithLimit(sqlMeta, false, needOrder, false, p * extractPageSize, p * extractPageSize + extractPageSize); + if (totalPage == 1) { + querySQL = SQLProvider.createQuerySQLWithLimit(sqlMeta, false, needOrder, false, 0, totalCount.intValue()); + } querySQL = provider.rebuildSQL(querySQL, sqlMeta, crossDs, dsMap); DatasourceRequest datasourceRequest = new DatasourceRequest(); datasourceRequest.setQuery(querySQL);