diff --git a/backend/pom.xml b/backend/pom.xml index 60ad36e102..ad2bbb4111 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -528,16 +528,21 @@ pentaho-public Pentaho Public - https://nexus.pentaho.org/content/groups/omni + https://repo.orl.eng.hitachivantara.com/artifactory/pnt-mvn/ true - always + daily true - always + interval:15 + + + clojars + https://repo.clojars.org/ + diff --git a/backend/src/main/java/io/dataease/auth/config/F2CRealm.java b/backend/src/main/java/io/dataease/auth/config/F2CRealm.java index 1bb7dc17d2..2084145759 100644 --- a/backend/src/main/java/io/dataease/auth/config/F2CRealm.java +++ b/backend/src/main/java/io/dataease/auth/config/F2CRealm.java @@ -11,6 +11,7 @@ import io.dataease.auth.service.AuthUserService; import io.dataease.auth.util.JWTUtils; import io.dataease.commons.utils.BeanUtils; import io.dataease.commons.utils.LogUtil; +import io.dataease.commons.utils.TokenCacheUtils; import io.dataease.listener.util.CacheUtils; import org.apache.shiro.authc.*; import org.apache.shiro.authz.AuthorizationInfo; @@ -83,6 +84,9 @@ public class F2CRealm extends AuthorizingRealm { token = (String) auth.getCredentials(); // 解密获得username,用于和数据库进行对比 tokenInfo = JWTUtils.tokenInfoByToken(token); + if (!TokenCacheUtils.validate(token)) { + throw new AuthenticationException("token invalid"); + } } catch (Exception e) { throw new AuthenticationException(e); } diff --git a/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java b/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java index a68673c3c1..464e0c0979 100644 --- a/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java +++ b/backend/src/main/java/io/dataease/auth/filter/JWTFilter.java @@ -10,6 +10,7 @@ import io.dataease.auth.service.AuthUserService; import io.dataease.auth.util.JWTUtils; import io.dataease.commons.utils.CommonBeanFactory; import io.dataease.commons.utils.LogUtil; +import io.dataease.commons.utils.TokenCacheUtils; import io.dataease.exception.DataEaseException; import io.dataease.i18n.Translator; import org.apache.commons.lang3.StringUtils; @@ -65,6 +66,9 @@ public class JWTFilter extends BasicHttpAuthenticationFilter { if (StringUtils.startsWith(authorization, "Basic")) { return false; } + if (!TokenCacheUtils.validate(authorization)) { + throw new AuthenticationException(expireMessage); + } // 当没有出现登录超时 且需要刷新token 则执行刷新token if (JWTUtils.loginExpire(authorization)) { throw new AuthenticationException(expireMessage); diff --git a/backend/src/main/java/io/dataease/auth/server/AuthServer.java b/backend/src/main/java/io/dataease/auth/server/AuthServer.java index 44fe78b13e..3eefede2df 100644 --- a/backend/src/main/java/io/dataease/auth/server/AuthServer.java +++ b/backend/src/main/java/io/dataease/auth/server/AuthServer.java @@ -234,6 +234,7 @@ public class AuthServer implements AuthApi { if (StringUtils.isBlank(result)) { result = "success"; } + TokenCacheUtils.remove(token); } catch (Exception e) { LogUtil.error(e); if (StringUtils.isBlank(result)) { @@ -287,6 +288,7 @@ public class AuthServer implements AuthApi { if (StringUtils.isBlank(result)) { result = "success"; } + TokenCacheUtils.remove(token); } catch (Exception e) { LogUtil.error(e); if (StringUtils.isBlank(result)) { diff --git a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java index 28072efd05..6d0aaef239 100644 --- a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java +++ b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java @@ -10,6 +10,7 @@ import com.auth0.jwt.interfaces.Verification; import io.dataease.auth.entity.TokenInfo; import io.dataease.auth.entity.TokenInfo.TokenInfoBuilder; import io.dataease.commons.utils.CommonBeanFactory; +import io.dataease.commons.utils.TokenCacheUtils; import io.dataease.exception.DataEaseException; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -117,7 +118,9 @@ public class JWTUtils { Builder builder = JWT.create() .withClaim("username", tokenInfo.getUsername()) .withClaim("userId", tokenInfo.getUserId()); - return builder.withExpiresAt(date).sign(algorithm); + String sign = builder.withExpiresAt(date).sign(algorithm); + TokenCacheUtils.add(sign, tokenInfo.getUserId()); + return sign; } catch (Exception e) { return null; diff --git a/backend/src/main/java/io/dataease/commons/utils/TokenCacheUtils.java b/backend/src/main/java/io/dataease/commons/utils/TokenCacheUtils.java new file mode 100644 index 0000000000..e17f293b51 --- /dev/null +++ b/backend/src/main/java/io/dataease/commons/utils/TokenCacheUtils.java @@ -0,0 +1,28 @@ +package io.dataease.commons.utils; + +import io.dataease.listener.util.CacheUtils; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; + +public class TokenCacheUtils { + + private static final String KEY = "sys_token_store"; + + public static void add(String token, Long userId) { + CacheUtils.put(KEY, token, userId, null, null); + } + + public static void remove(String token) { + CacheUtils.remove(KEY, token); + } + + public static boolean validate(String token) { + Object sys_token_store = CacheUtils.get(KEY, token); + return ObjectUtils.isNotEmpty(sys_token_store) && StringUtils.isNotBlank(sys_token_store.toString()); + } + + public static boolean validate(String token, Long userId) { + Object sys_token_store = CacheUtils.get(KEY, token); + return ObjectUtils.isNotEmpty(sys_token_store) && StringUtils.isNotBlank(sys_token_store.toString()) && userId == Long.parseLong(sys_token_store.toString()); + } +} diff --git a/backend/src/main/java/io/dataease/controller/request/datasource/ApiDefinition.java b/backend/src/main/java/io/dataease/controller/request/datasource/ApiDefinition.java index b3689548c6..540081cefa 100644 --- a/backend/src/main/java/io/dataease/controller/request/datasource/ApiDefinition.java +++ b/backend/src/main/java/io/dataease/controller/request/datasource/ApiDefinition.java @@ -26,5 +26,7 @@ public class ApiDefinition { private boolean useJsonPath; private String jsonPath; private boolean showApiStructure; + private boolean reName = false; + private String orgName; } diff --git a/backend/src/main/java/io/dataease/provider/datasource/ApiProvider.java b/backend/src/main/java/io/dataease/provider/datasource/ApiProvider.java index c1e5c73141..ddbcb5c9e0 100644 --- a/backend/src/main/java/io/dataease/provider/datasource/ApiProvider.java +++ b/backend/src/main/java/io/dataease/provider/datasource/ApiProvider.java @@ -266,13 +266,11 @@ public class ApiProvider extends Provider { for (String s : jsonObject.keySet()) { String value = jsonObject.getString(s); if (StringUtils.isNotEmpty(value) && value.startsWith("[")) { - JSONObject o = new JSONObject(); try { JSONArray jsonArray = jsonObject.getJSONArray(s); List childrenField = new ArrayList<>(); for (Object object : jsonArray) { - JSONObject.parseObject(object.toString()); handleStr(apiDefinition, JSON.toJSONString(object, SerializerFeature.WriteMapNullValue), childrenField, rootPath + "." + s + "[*]"); } o.put("children", childrenField); @@ -289,15 +287,28 @@ public class ApiProvider extends Provider { fields.add(o); } } else if (StringUtils.isNotEmpty(value) && value.startsWith("{")) { - List children = new ArrayList<>(); - handleStr(apiDefinition, jsonObject.getString(s), children, rootPath + "." + String.format(path, s)); - JSONObject o = new JSONObject(); - o.put("children", children); - o.put("childrenDataType", "OBJECT"); - o.put("jsonPath", rootPath + "." + s); - setProperty(apiDefinition, o, s); - if (!hasItem(apiDefinition, fields, o)) { - fields.add(o); + try { + JSONObject.parseObject(jsonStr); + List children = new ArrayList<>(); + handleStr(apiDefinition, jsonObject.getString(s), children, rootPath + "." + String.format(path, s)); + JSONObject o = new JSONObject(); + o.put("children", children); + o.put("childrenDataType", "OBJECT"); + o.put("jsonPath", rootPath + "." + s); + setProperty(apiDefinition, o, s); + if (!hasItem(apiDefinition, fields, o)) { + fields.add(o); + } + }catch (Exception e){ + JSONObject o = new JSONObject(); + o.put("jsonPath", rootPath + "." + String.format(path, s)); + setProperty(apiDefinition, o, s); + JSONArray array = new JSONArray(); + array.add(StringUtils.isNotEmpty(jsonObject.getString(s)) ? jsonObject.getString(s) : ""); + o.put("value", array); + if (!hasItem(apiDefinition, fields, o)) { + fields.add(o); + } } } else { JSONObject o = new JSONObject(); @@ -325,13 +336,13 @@ public class ApiProvider extends Provider { o.put("deType", 0); o.put("extField", 0); o.put("checked", false); - for (DatasetTableFieldDTO fieldDTO : apiDefinition.getFields()) { - if (StringUtils.isNotEmpty(o.getString("jsonPath")) && StringUtils.isNotEmpty(fieldDTO.getJsonPath()) && fieldDTO.getJsonPath().equals(o.getString("jsonPath"))) { - o.put("checked", true); - o.put("deExtractType", fieldDTO.getDeExtractType()); - o.put("name", fieldDTO.getName()); - } - } +// for (DatasetTableFieldDTO fieldDTO : apiDefinition.getFields()) { +// if (StringUtils.isNotEmpty(o.getString("jsonPath")) && StringUtils.isNotEmpty(fieldDTO.getJsonPath()) && fieldDTO.getJsonPath().equals(o.getString("jsonPath"))) { +// o.put("checked", true); +// o.put("deExtractType", fieldDTO.getDeExtractType()); +// o.put("name", fieldDTO.getName()); +// } +// } } diff --git a/backend/src/main/java/io/dataease/service/datasource/DatasourceService.java b/backend/src/main/java/io/dataease/service/datasource/DatasourceService.java index c29f1bf94a..76d2f12ef4 100644 --- a/backend/src/main/java/io/dataease/service/datasource/DatasourceService.java +++ b/backend/src/main/java/io/dataease/service/datasource/DatasourceService.java @@ -284,7 +284,6 @@ public class DatasourceService { datasource.setUpdateTime(System.currentTimeMillis()); Provider datasourceProvider = ProviderFactory.getProvider(updataDsRequest.getType()); datasourceProvider.checkConfiguration(datasource); - checkAndUpdateDatasourceStatus(datasource); updateDatasource(updataDsRequest.getId(), datasource); } @@ -295,6 +294,28 @@ public class DatasourceService { checkAndUpdateDatasourceStatus(datasource); datasourceMapper.updateByExampleSelective(datasource, example); handleConnectionPool(id); + + if (datasource.getType().equalsIgnoreCase("api")) { + DatasetTableExample datasetTableExample = new DatasetTableExample(); + datasetTableExample.createCriteria().andDataSourceIdEqualTo(id); + List datasetTables = datasetTableMapper.selectByExample(datasetTableExample); + List apiDefinitionList = new Gson().fromJson(datasource.getConfiguration(), new TypeToken>() {}.getType()); + apiDefinitionList.forEach(apiDefinition -> { + if(apiDefinition.isReName()){ + datasetTables.forEach(datasetTable -> { + if(new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class).getTable().equals(apiDefinition.getOrgName())){ + DatasetTable record = new DatasetTable(); + DataTableInfoDTO dataTableInfoDTO = new DataTableInfoDTO(); + dataTableInfoDTO.setTable(apiDefinition.getName()); + record.setInfo(new Gson().toJson(dataTableInfoDTO)); + datasetTableExample.clear(); + datasetTableExample.createCriteria().andIdEqualTo(datasetTable.getId()); + datasetTableMapper.updateByExampleSelective(record, datasetTableExample); + } + }); + } + }); + } } private void handleConnectionPool(String datasourceId) { @@ -340,6 +361,7 @@ public class DatasourceService { datasourceDTO.setApiConfiguration(apiDefinitionListWithStatus); if (success == apiDefinitionList.size()) { + datasource.setStatus(datasourceStatus); return ResultHolder.success(datasourceDTO); } if (success > 0 && success < apiDefinitionList.size()) { diff --git a/backend/src/main/resources/db/migration/V49__1.18.2.sql b/backend/src/main/resources/db/migration/V49__1.18.2.sql index 5306f8280c..a883405b2f 100644 --- a/backend/src/main/resources/db/migration/V49__1.18.2.sql +++ b/backend/src/main/resources/db/migration/V49__1.18.2.sql @@ -3,6 +3,10 @@ SET `version` = '1.18.2' where `plugin_id` > 0 and `version` = '1.18.1'; +UPDATE sys_menu +SET i_frame = 1 +WHERE menu_id = 800; + UPDATE `panel_subject` SET `details` = '{\"width\":1600,\"height\":900,\"scale\":100,\"scaleWidth\":100,\"scaleHeight\":100,\"selfAdaption\":true,\"auxiliaryMatrix\":true,\"openCommonStyle\":true,\"panel\":{\"themeColor\":\"light\",\"color\":\"#F1F3F5\",\"imageUrl\":{},\"backgroundType\":\"color\",\"gap\":\"yes\",\"resultMode\":\"all\",\"resultCount\":1000},\"aidedDesign\":{\"showGrid\":false,\"matrixBase\":4},\"refreshViewLoading\":true,\"refreshUnit\":\"minute\",\"refreshTime\":5,\"themeId\":\"e846db60-9619-11ed-b973-39e0420a3eeb\",\"chartInfo\":{\"chartTitle\":{\"show\":true,\"fontSize\":\"18\",\"color\":\"#000000\",\"hPosition\":\"left\",\"vPosition\":\"top\",\"isItalic\":false,\"isBolder\":true,\"remarkShow\":false,\"remark\":\"\",\"remarkBackgroundColor\":\"#ffffffff\",\"fontFamily\":\"Microsoft YaHei\",\"letterSpace\":\"0\",\"fontShadow\":false},\"chartColor\":{\"value\":\"default\",\"colors\":[\"#5470c6\",\"#91cc75\",\"#fac858\",\"#ee6666\",\"#73c0de\",\"#3ba272\",\"#fc8452\",\"#9a60b4\",\"#ea7ccc\"],\"alpha\":100,\"tableHeaderBgColor\":\"#6D9A49\",\"tableItemBgColor\":\"#FFFFFF\",\"tableHeaderFontColor\":\"#000000\",\"tableFontColor\":\"#000000\",\"tableStripe\":true,\"dimensionColor\":\"#000000\",\"quotaColor\":\"#5470c6\",\"tableBorderColor\":\"#E6E7E4\",\"seriesColors\":[],\"areaBorderColor\":\"#303133\",\"gradient\":false,\"areaBaseColor\":\"#FFFFFF\",\"tableScrollBarColor\":\"rgba(0, 0, 0, 0.15)\",\"tableScrollBarHoverColor\":\"rgba(0, 0, 0, 0.4)\"},\"chartCommonStyle\":{\"backgroundColorSelect\":true,\"color\":\"#FFFFFF\",\"alpha\":100,\"borderRadius\":5,\"innerPadding\":0,\"enable\":false,\"innerImageColor\":\"#1E90FF\",\"backgroundType\":\"outerImage\",\"outerImage\":null},\"filterStyle\":{\"horizontal\":\"left\",\"vertical\":\"top\",\"color\":\"#000000\",\"brColor\":\"\",\"wordColor\":\"\",\"innerBgColor\":\"\"},\"tabStyle\":{\"headFontColor\":\"#OOOOOO\",\"headFontActiveColor\":\"#OOOOOO\",\"headBorderColor\":\"#OOOOOO\",\"headBorderActiveColor\":\"#OOOOOO\",\"headPosition\":\"left\"}}}' WHERE `id` = 'system_1'; diff --git a/backend/src/main/resources/ehcache/ehcache.xml b/backend/src/main/resources/ehcache/ehcache.xml index e4086c3e04..c1fedd7f25 100644 --- a/backend/src/main/resources/ehcache/ehcache.xml +++ b/backend/src/main/resources/ehcache/ehcache.xml @@ -270,5 +270,14 @@ memoryStoreEvictionPolicy="LRU" /> + + \ No newline at end of file diff --git a/frontend/src/views/system/datasource/DsConfiguration.vue b/frontend/src/views/system/datasource/DsConfiguration.vue index 00e4cc5360..32cefd2a3b 100644 --- a/frontend/src/views/system/datasource/DsConfiguration.vue +++ b/frontend/src/views/system/datasource/DsConfiguration.vue @@ -1222,14 +1222,15 @@ export default { this.edit_api_item = false if (!this.add_api_item) { for (let i = 0; i < this.form.apiConfiguration.length; i++) { - if ( - this.form.apiConfiguration[i].serialNumber === - this.apiItem.serialNumber - ) { - this.form.apiConfiguration[i] = JSON.parse( - JSON.stringify(this.apiItem) - ) + if (this.form.apiConfiguration[i].serialNumber === this.apiItem.serialNumber) { this.certinKey = !this.certinKey + if(this.form.apiConfiguration[i].name !== this.apiItem.name){ + this.apiItem.reName = true + this.apiItem.orgName = this.form.apiConfiguration[i].name + }else { + this.apiItem.reName = false + } + this.form.apiConfiguration[i] = JSON.parse(JSON.stringify(this.apiItem)) } } } else {