Skip to content

Commit ffb7146

Browse files
authored
Merge pull request dataease#12066 from dataease/dev
merge Dev
2 parents 0164367 + df3e6b1 commit ffb7146

File tree

17 files changed

+169
-37
lines changed

17 files changed

+169
-37
lines changed

core/backend/src/main/java/io/dataease/auth/config/cas/CasStrategy.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package io.dataease.auth.config.cas;
22

3+
import com.auth0.jwt.JWT;
4+
import com.auth0.jwt.interfaces.Claim;
5+
import com.auth0.jwt.interfaces.DecodedJWT;
36
import io.dataease.auth.service.impl.ShiroServiceImpl;
47
import io.dataease.commons.utils.CommonBeanFactory;
8+
import io.dataease.commons.utils.LogUtil;
59
import io.dataease.commons.utils.ServletUtils;
610
import io.dataease.service.system.SystemParameterService;
11+
import org.apache.commons.lang3.ObjectUtils;
712
import org.apache.commons.lang3.StringUtils;
813
import org.apache.shiro.util.AntPathMatcher;
914
import org.jasig.cas.client.authentication.UrlPatternMatcherStrategy;
@@ -38,9 +43,9 @@ public boolean matches(String s) {
3843
s = s.substring(beginIndex + serverName.length());
3944
}
4045
if (StringUtils.equals("/", s)) {
41-
if (fromLink(serverName)) return true;
42-
return false;
46+
return fromLink(serverName);
4347
}
48+
if (fromShot()) return true;
4449
if (StringUtils.equals("/login", s)) return false;
4550
if (StringUtils.startsWith(s, "/cas/callBack")) return false;
4651
if (StringUtils.equals("/api/auth/deLogout", s)) return true;
@@ -74,4 +79,17 @@ private Boolean fromLink(String serverName) {
7479
}
7580
return false;
7681
}
82+
83+
private Boolean fromShot() {
84+
String token = ServletUtils.getToken();
85+
if (StringUtils.isBlank(token)) return false;
86+
try {
87+
DecodedJWT jwt = JWT.decode(token);
88+
Claim forShot = jwt.getClaim("forShot");
89+
return ObjectUtils.isNotEmpty(forShot) && forShot.asBoolean();
90+
} catch (Exception e) {
91+
LogUtil.error(e.getMessage());
92+
return false;
93+
}
94+
}
7795
}

core/backend/src/main/java/io/dataease/auth/util/JWTUtils.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,18 @@ public static String seizeSign(Long userId, String token) {
125125
return IPUtils.get();
126126
}
127127

128+
public static String signShotToken(TokenInfo tokenInfo, String secret) {
129+
Long userId = tokenInfo.getUserId();
130+
long expireTimeMillis = getExpireTime();
131+
Date date = new Date(System.currentTimeMillis() + expireTimeMillis);
132+
Algorithm algorithm = Algorithm.HMAC256(secret);
133+
Builder builder = JWT.create()
134+
.withClaim("username", tokenInfo.getUsername())
135+
.withClaim("forShot", true)
136+
.withClaim("userId", userId);
137+
return builder.withExpiresAt(date).sign(algorithm);
138+
}
139+
128140
public static String sign(TokenInfo tokenInfo, String secret, boolean writeOnline) {
129141

130142
Long userId = tokenInfo.getUserId();

core/backend/src/main/java/io/dataease/job/sechedule/strategy/impl/EmailTaskHandler.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,18 @@ private XpackPixelEntity buildPixel(XpackEmailTemplateDTO emailTemplateDTO) {
435435

436436
private String tokenByUser(SysUserEntity user) {
437437
TokenInfo tokenInfo = TokenInfo.builder().userId(user.getUserId()).username(user.getUsername()).build();
438-
String token = JWTUtils.sign(tokenInfo, user.getPassword(), false);
439-
440-
return token;
438+
return JWTUtils.signShotToken(tokenInfo, user.getPassword());
441439
}
442440

443441
private String panelUrl(String panelId) {
444442
String domain = ServletUtils.domain();
445443
return domain + "/#/previewScreenShot/" + panelId + "/true";
446444
}
447445

446+
public static void main(String[] args) {
447+
TokenInfo tokenInfo = TokenInfo.builder().userId(1L).username("admin").build();
448+
String contextPath = JWTUtils.signShotToken(tokenInfo, "ae8000252199d4f2aa00e3b99e6f9934");
449+
System.out.println(contextPath);
450+
}
451+
448452
}

core/backend/src/main/java/io/dataease/service/dataset/impl/direct/DirectFieldService.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package io.dataease.service.dataset.impl.direct;
22

33
import com.google.gson.Gson;
4+
import io.dataease.auth.entity.SysUserEntity;
5+
import io.dataease.auth.service.AuthUserService;
46
import io.dataease.commons.model.BaseTreeNode;
7+
import io.dataease.commons.utils.AuthUtils;
58
import io.dataease.commons.utils.BeanUtils;
69
import io.dataease.commons.utils.LogUtil;
710
import io.dataease.commons.utils.TreeUtils;
11+
import io.dataease.dto.dataset.DataSetTableDTO;
812
import io.dataease.dto.dataset.DataSetTableUnionDTO;
913
import io.dataease.plugins.common.dto.dataset.DataTableInfoDTO;
1014
import io.dataease.dto.dataset.DeSortDTO;
@@ -53,6 +57,8 @@ public class DirectFieldService implements DataSetFieldService {
5357
private EngineService engineService;
5458
@Resource
5559
private PermissionsTreeService permissionsTreeService;
60+
@Resource
61+
private AuthUserService authUserService;
5662

5763
@Override
5864
public List<Object> fieldValues(String fieldId, Long userId, Boolean userPermissions, Boolean rowAndColumnMgm) throws Exception {
@@ -107,7 +113,13 @@ public List<Object> fieldValues(List<String> fieldIds, DeSortDTO sortDTO, Long u
107113

108114
DatasetTable datasetTable = dataSetTableService.get(field.getTableId());
109115
if (ObjectUtils.isEmpty(datasetTable) || StringUtils.isEmpty(datasetTable.getName())) return null;
110-
116+
SysUserEntity userEntity = userId != null ? authUserService.getUserById(userId) : AuthUtils.getUser();
117+
if (userEntity != null && !userEntity.getIsAdmin()) {
118+
DataSetTableDTO withPermission = dataSetTableService.getWithPermission(datasetTable.getId(), userEntity.getUserId());
119+
if (ObjectUtils.isEmpty(withPermission.getPrivileges()) || !withPermission.getPrivileges().contains("use")) {
120+
DataEaseException.throwException(Translator.get("i18n_dataset_no_permission") + String.format(":table name [%s]", withPermission.getName()));
121+
}
122+
}
111123
DatasetTableField datasetTableField = DatasetTableField.builder().tableId(field.getTableId()).checked(Boolean.TRUE).build();
112124
List<DatasetTableField> fields = dataSetTableFieldsService.list(datasetTableField);
113125

core/frontend/public/link.html

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,39 @@
2929
}
3030
return (false)
3131
}
32-
const link = getQueryVariable('link')
33-
const user = getQueryVariable('user')
34-
const terminal = getQueryVariable('terminal')
35-
const attachParams = getQueryVariable('attachParams')
36-
const fromLink = getQueryVariable('fromLink')
37-
const ticket = getQueryVariable('ticket')
38-
const baseUrl = window.location.pathname.replace('link.html', '')
39-
let url = baseUrl + "#/delink?link=" + encodeURIComponent(link)
40-
if (terminal) {
41-
url += '&terminal=' + terminal
42-
}
43-
if (user) {
44-
url += '&user=' + encodeURIComponent(user)
45-
}
46-
if (attachParams) {
47-
url += '&attachParams=' + encodeURIComponent(attachParams)
48-
}
49-
if (fromLink) {
50-
url += '&fromLink=' + fromLink
51-
}
52-
if (ticket) {
53-
url += '&ticket=' + ticket
32+
const shot = getQueryVariable('shot')
33+
if (shot) {
34+
const panelId = getQueryVariable('panelId')
35+
const baseUrl = window.location.pathname.replace('link.html', '')
36+
const shoturl = baseUrl + "#/previewScreenShot/" + panelId + "/true"
37+
window.location.href = shoturl
38+
} else {
39+
const link = getQueryVariable('link')
40+
const user = getQueryVariable('user')
41+
const terminal = getQueryVariable('terminal')
42+
const attachParams = getQueryVariable('attachParams')
43+
const fromLink = getQueryVariable('fromLink')
44+
const ticket = getQueryVariable('ticket')
45+
const baseUrl = window.location.pathname.replace('link.html', '')
46+
let url = baseUrl + "#/delink?link=" + encodeURIComponent(link)
47+
if (terminal) {
48+
url += '&terminal=' + terminal
49+
}
50+
if (user) {
51+
url += '&user=' + encodeURIComponent(user)
52+
}
53+
if (attachParams) {
54+
url += '&attachParams=' + encodeURIComponent(attachParams)
55+
}
56+
if (fromLink) {
57+
url += '&fromLink=' + fromLink
58+
}
59+
if (ticket) {
60+
url += '&ticket=' + ticket
61+
}
62+
window.location.href = url
5463
}
55-
window.location.href = url
64+
5665
</script>
5766

5867
</html>

core/frontend/src/components/canvas/components/editor/Preview.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
@back-to-top="backToTop"
1717
/>
1818
<link-opt-bar
19-
v-if="canvasId==='canvas-main'"
19+
v-if="linkOptBarShow"
2020
ref="link-opt-bar"
2121
:terminal="terminal"
2222
:canvas-style-data="canvasStyleData"
@@ -382,6 +382,9 @@ export default {
382382
}
383383
},
384384
computed: {
385+
linkOptBarShow() {
386+
return this.canvasId==='canvas-main' && this.canvasStyleData.showPublicLinkButton
387+
},
385388
screenShotStatues() {
386389
return this.exporting || this.screenShot || this.backScreenShot
387390
},

core/frontend/src/components/canvas/utils/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export function panelDataPrepare(componentData, componentStyle, callback) {
9494
componentStyle.refreshUnit = (componentStyle.refreshUnit || 'minute')
9595
componentStyle.refreshViewEnable = (componentStyle.refreshViewEnable === undefined ? true : componentStyle.refreshViewEnable)
9696
componentStyle.refreshBrowserEnable = (componentStyle.refreshBrowserEnable || false)
97+
componentStyle.showPublicLinkButton = (componentStyle.showPublicLinkButton === undefined ? true : componentStyle.showPublicLinkButton)
9798
componentStyle.refreshBrowserTime = (componentStyle.refreshBrowserTime || 5)
9899
componentStyle.aidedDesign = (componentStyle.aidedDesign || deepCopy(AIDED_DESIGN))
99100
componentStyle.pdfPageLine = (componentStyle.pdfPageLine || deepCopy(PAGE_LINE_DESIGN))

core/frontend/src/lang/en.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,9 @@ export default {
16151615
table_freeze: 'Table Freeze',
16161616
table_config: 'Table Config',
16171617
table_column_width_config: 'Column Width',
1618+
table_layout_mode: 'Layout Mode',
1619+
table_layout_grid: 'Grid',
1620+
table_layout_tree: 'Tree',
16181621
table_column_adapt: 'Adapt',
16191622
table_column_custom: 'Custom',
16201623
table_column_fixed: 'Fixed',
@@ -2396,7 +2399,9 @@ export default {
23962399
theme_color_light: 'Light',
23972400
refresh_frequency: 'Refresh Frequency',
23982401
refresh_browser_frequency: 'Refresh Browser',
2402+
public_link_button_show: 'Show Public Link Button',
23992403
refresh_browser_tips: 'Only public links are effective',
2404+
public_link_button_tips: 'Only public links are effective',
24002405
card_color_matching: 'Card Color Matching',
24012406
table_color_matching: 'Table Color Matching',
24022407
background_color: 'Background Color',

core/frontend/src/lang/tw.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,9 @@ export default {
16131613
column: '列',
16141614
table_config: '表格配置',
16151615
table_column_width_config: '列寬調整',
1616+
table_layout_mode: '展示形式',
1617+
table_layout_grid: '平鋪展示',
1618+
table_layout_tree: '樹形模式',
16161619
table_freeze: '表格凍結',
16171620
table_column_adapt: '自適應',
16181621
table_column_custom: '自定義',
@@ -2389,7 +2392,9 @@ export default {
23892392
theme_color_light: '淺色',
23902393
refresh_frequency: '刷新頻率',
23912394
refresh_browser_frequency: '瀏覽器刷新',
2395+
public_link_button_show: '顯示公共鏈接操作按鈕',
23922396
refresh_browser_tips: '僅公共鏈接生效',
2397+
public_link_button_tips: '僅公共鏈接生效',
23932398
card_color_matching: '卡片配色',
23942399
table_color_matching: '表格配色',
23952400
background_color: '背景顏色',

core/frontend/src/lang/zh.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,9 @@ export default {
16111611
table_freeze: '表格冻结',
16121612
table_config: '表格配置',
16131613
table_column_width_config: '列宽调整',
1614+
table_layout_mode: '展示形式',
1615+
table_layout_grid: '平铺展示',
1616+
table_layout_tree: '树形模式',
16141617
table_column_adapt: '自适应',
16151618
table_column_custom: '自定义',
16161619
table_column_fixed: '固定列宽',
@@ -2390,7 +2393,9 @@ export default {
23902393
theme_color_light: '浅色',
23912394
refresh_frequency: '刷新频率',
23922395
refresh_browser_frequency: '浏览器刷新',
2396+
public_link_button_show: '显示公共链接操作按钮',
23932397
refresh_browser_tips: '仅公共链接生效',
2398+
public_link_button_tips: '仅公共链接生效',
23942399
card_color_matching: '卡片配色',
23952400
table_color_matching: '表格配色',
23962401
background_color: '背景颜色',

0 commit comments

Comments
 (0)