From 2365d3f24e2e2dd2717b50b76c0197b68c0fcd11 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Sat, 18 Dec 2021 22:35:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E7=AB=AF=E4=BB=AA=E8=A1=A8=E6=9D=BFapi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/service/impl/ShiroServiceImpl.java | 19 ++++++++++--------- .../dataease/controller/IndexController.java | 17 ++++++++++++++++- frontend/src/utils/request.js | 9 ++++----- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/backend/src/main/java/io/dataease/auth/service/impl/ShiroServiceImpl.java b/backend/src/main/java/io/dataease/auth/service/impl/ShiroServiceImpl.java index 781e02c3c8..4e1401ccaf 100644 --- a/backend/src/main/java/io/dataease/auth/service/impl/ShiroServiceImpl.java +++ b/backend/src/main/java/io/dataease/auth/service/impl/ShiroServiceImpl.java @@ -12,12 +12,12 @@ public class ShiroServiceImpl implements ShiroService { private final static String ANON = "anon"; - @Override public Map loadFilterChainDefinitionMap() { // 权限控制map Map filterChainDefinitionMap = new LinkedHashMap<>(); - // 配置过滤:不会被拦截的链接 -> 放行 start ---------------------------------------------------------- + // 配置过滤:不会被拦截的链接 -> 放行 start + // ---------------------------------------------------------- // 放行Swagger2页面,需要放行这些 filterChainDefinitionMap.put("/doc.html**", "doc"); @@ -42,17 +42,20 @@ public class ShiroServiceImpl implements ShiroService { filterChainDefinitionMap.put("/index.html", ANON); filterChainDefinitionMap.put("/link.html", ANON); - - //获取主题信息 + // 获取主题信息 filterChainDefinitionMap.put("/plugin/theme/themes", ANON); filterChainDefinitionMap.put("/plugin/theme/items/**", ANON); - //验证链接 + // 验证链接 filterChainDefinitionMap.put("/api/link/validate**", ANON); filterChainDefinitionMap.put("/api/map/areaEntitys/**", ANON); filterChainDefinitionMap.put("/dataset/field/fieldValues/**", ANON); filterChainDefinitionMap.put("/linkJump/queryPanelJumpInfo/**", ANON); + filterChainDefinitionMap.put("/tempMobileLink/**", ANON); + filterChainDefinitionMap.put("/de-app/**", ANON); + filterChainDefinitionMap.put("/app.html", ANON); + filterChainDefinitionMap.put("/**/*.json", ANON); filterChainDefinitionMap.put("/system/ui/**", ANON); filterChainDefinitionMap.put("/**/*.js", ANON); @@ -70,7 +73,6 @@ public class ShiroServiceImpl implements ShiroService { filterChainDefinitionMap.put("/plugin/oidc/authInfo", ANON); filterChainDefinitionMap.put("/sso/callBack*", ANON); - filterChainDefinitionMap.put("/unauth", ANON); filterChainDefinitionMap.put("/display/**", ANON); filterChainDefinitionMap.put("/tokenExpired", ANON); @@ -82,7 +84,6 @@ public class ShiroServiceImpl implements ShiroService { filterChainDefinitionMap.put("/api/link/resourceDetail/**", "link"); filterChainDefinitionMap.put("/api/link/viewDetail/**", "link"); - filterChainDefinitionMap.put("/**", "authc"); filterChainDefinitionMap.put("/**", "jwt"); @@ -90,9 +91,9 @@ public class ShiroServiceImpl implements ShiroService { return filterChainDefinitionMap; } - @Override - public void updatePermission(ShiroFilterFactoryBean shiroFilterFactoryBean, Integer roleId, Boolean isRemoveSession) { + public void updatePermission(ShiroFilterFactoryBean shiroFilterFactoryBean, Integer roleId, + Boolean isRemoveSession) { } diff --git a/backend/src/main/java/io/dataease/controller/IndexController.java b/backend/src/main/java/io/dataease/controller/IndexController.java index 8313e3c491..eaa82d128d 100644 --- a/backend/src/main/java/io/dataease/controller/IndexController.java +++ b/backend/src/main/java/io/dataease/controller/IndexController.java @@ -19,6 +19,7 @@ import java.io.IOException; @RequestMapping public class IndexController { + private static final int FOR_EVER = 3600 * 24 * 30 * 12 * 10; // 10 years in second @Resource private DefaultLicenseService defaultLicenseService; @@ -35,7 +36,6 @@ public class IndexController { return "index.html"; } - @GetMapping("/deApi") public String deApi() { F2CLicenseResponse f2CLicenseResponse = defaultLicenseService.validateLicense(); @@ -59,5 +59,20 @@ public class IndexController { } } + @GetMapping("/tempMobileLink/{id}/{token}") + public void tempMobileLink(@PathVariable("id") String id, @PathVariable("token") String token) { + String url = "http://localhost:8081/#preview/" + id; + HttpServletResponse response = ServletUtils.response(); + Cookie cookie = new Cookie("Authorization", token); + cookie.setPath("/"); + cookie.setMaxAge(FOR_EVER); + response.addCookie(cookie); + try { + response.sendRedirect(url); + } catch (IOException e) { + LogUtil.error(e.getMessage()); + DEException.throwException(e); + } + } } diff --git a/frontend/src/utils/request.js b/frontend/src/utils/request.js index 44be108641..fa250e5cad 100644 --- a/frontend/src/utils/request.js +++ b/frontend/src/utils/request.js @@ -1,18 +1,17 @@ import axios from 'axios' import store from '@/store' -import {$alert, $error} from './message' -import {getToken, getIdToken} from '@/utils/auth' +import { $alert, $error } from './message' +import { getToken, getIdToken } from '@/utils/auth' import Config from '@/settings' import i18n from '@/lang' -import {tryShowLoading, tryHideLoading} from './loading' -import {getLinkToken, setLinkToken} from '@/utils/auth' +import { tryShowLoading, tryHideLoading } from './loading' +import { getLinkToken, setLinkToken } from '@/utils/auth' const TokenKey = Config.TokenKey const RefreshTokenKey = Config.RefreshTokenKey const LinkTokenKey = Config.LinkTokenKey import Cookies from 'js-cookie' - const getTimeOut = () => { let time = 10 const url = '/system/requestTimeOut'