-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
jimureport-example/src/main/java/com/jeecg/modules/jmreport/config/ViewPageCustomAccess.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.jeecg.modules.jmreport.config; | ||
|
||
import org.jeecg.modules.jmreport.common.util.OkConvertUtils; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
/** | ||
* 自定义view页面access处理 | ||
* for: [TV360X-2206] 目前这个版本必须登录后才能看报表,如何设置不登录也能查看报表 #2919 | ||
* @author chenrui | ||
* @date 2024/8/23 14:28 | ||
*/ | ||
@Component("viewPageCustomAccess") | ||
public class ViewPageCustomAccess { | ||
|
||
@Value("${spring.security.open-view-page:false}") | ||
boolean openViewPage = false; | ||
|
||
public boolean check(HttpServletRequest request, Authentication authentication) { | ||
Object principal = authentication.getPrincipal(); | ||
if (OkConvertUtils.isEmpty(principal) || "anonymousUser".equalsIgnoreCase(principal.toString())) { | ||
// 未登录 | ||
if (openViewPage) { | ||
// 配置文件设置了开放view页面 | ||
return true; | ||
} | ||
HttpServletRequest httpRequest = (HttpServletRequest) request; | ||
String previousPage = httpRequest.getParameter("previousPage"); | ||
String jmLink = httpRequest.getParameter("jmLink"); | ||
if (OkConvertUtils.isNotEmpty(previousPage) && OkConvertUtils.isNotEmpty(jmLink) ) { | ||
// 参数中有previousPage和jmLink | ||
return true; | ||
} | ||
return false; | ||
} | ||
return true; | ||
} | ||
} | ||
|