diff --git a/backend/src/main/java/io/dataease/auth/config/ShiroConfig.java b/backend/src/main/java/io/dataease/auth/config/ShiroConfig.java index a3d6e190de..764aefb3f3 100644 --- a/backend/src/main/java/io/dataease/auth/config/ShiroConfig.java +++ b/backend/src/main/java/io/dataease/auth/config/ShiroConfig.java @@ -51,6 +51,7 @@ public class ShiroConfig { filterMap.put("jwt", new JWTFilter()); filterMap.put("logout", new F2CLogoutFilter()); filterMap.put("link", new F2CLinkFilter()); + filterMap.put("doc", new F2CDocFilter()); factoryBean.setSecurityManager(securityManager); factoryBean.setLoginUrl("/login"); factoryBean.setUnauthorizedUrl("/login"); diff --git a/backend/src/main/java/io/dataease/auth/filter/F2CDocFilter.java b/backend/src/main/java/io/dataease/auth/filter/F2CDocFilter.java new file mode 100644 index 0000000000..022180c4b3 --- /dev/null +++ b/backend/src/main/java/io/dataease/auth/filter/F2CDocFilter.java @@ -0,0 +1,26 @@ +package io.dataease.auth.filter; + +import org.apache.shiro.web.filter.authc.AnonymousFilter; + +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; + +public class F2CDocFilter extends AnonymousFilter { + + @Override + protected boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue) { + HttpServletRequest req = (HttpServletRequest) request; + String path = "/deApi"; + try { + req.getRequestDispatcher(path).forward(req, response); + } catch (ServletException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return true; + } +} 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 a6cdf4ec83..c12a511e21 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 @@ -20,7 +20,8 @@ public class ShiroServiceImpl implements ShiroService { // 配置过滤:不会被拦截的链接 -> 放行 start ---------------------------------------------------------- // 放行Swagger2页面,需要放行这些 - filterChainDefinitionMap.put("/doc.html",ANON); + filterChainDefinitionMap.put("/doc.html**","doc"); + filterChainDefinitionMap.put("/deApi**",ANON); filterChainDefinitionMap.put("/swagger-ui.html",ANON); filterChainDefinitionMap.put("/swagger-ui/**",ANON); filterChainDefinitionMap.put("/swagger/**",ANON); diff --git a/backend/src/main/java/io/dataease/controller/IndexController.java b/backend/src/main/java/io/dataease/controller/IndexController.java index 7a48d8f564..19c83d007f 100644 --- a/backend/src/main/java/io/dataease/controller/IndexController.java +++ b/backend/src/main/java/io/dataease/controller/IndexController.java @@ -1,13 +1,21 @@ package io.dataease.controller; +import io.dataease.commons.license.DefaultLicenseService; +import io.dataease.commons.license.F2CLicenseResponse; +import io.dataease.exception.DataEaseException; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import javax.annotation.Resource; + @Controller @RequestMapping public class IndexController { + @Resource + private DefaultLicenseService defaultLicenseService; + @GetMapping(value = "/") public String index() { return "index.html"; @@ -28,5 +36,18 @@ public class IndexController { return "test.html"; } + @GetMapping("/deApi") + public String deApi() { + F2CLicenseResponse f2CLicenseResponse = defaultLicenseService.validateLicense(); + switch (f2CLicenseResponse.getStatus()) { + case valid: + return "doc.html"; + default: + // DataEaseException.throwException("Invalid License."); + return "nolic.html"; + } + // return "index.html"; + } + } diff --git a/frontend/public/nolic.html b/frontend/public/nolic.html new file mode 100644 index 0000000000..89f3ecbc52 --- /dev/null +++ b/frontend/public/nolic.html @@ -0,0 +1,13 @@ + + +
+ + + + +