Commit 39bf9cf5b0cbdadd9167718d4bfebe5d885fa03e
1 parent
2a4882e8
【代码修复】REPORT:修复积木在访问 jmreport/index 会报错的问题
Showing
2 changed files
with
9 additions
and
5 deletions
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/jmreport/core/service/JmReportTokenServiceImpl.java
| ... | ... | @@ -133,6 +133,13 @@ public class JmReportTokenServiceImpl implements JmReportTokenServiceI { |
| 133 | 133 | |
| 134 | 134 | @Override |
| 135 | 135 | public String[] getRoles(String token) { |
| 136 | + // 设置租户上下文。原因是:/jmreport/** 纯前端地址,不会走 buildLoginUserByToken 逻辑 | |
| 137 | + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); | |
| 138 | + if (loginUser == null) { | |
| 139 | + return null; | |
| 140 | + } | |
| 141 | + TenantContextHolder.setTenantId(loginUser.getTenantId()); | |
| 142 | + | |
| 136 | 143 | // 参见文档 https://help.jeecg.com/jimureport/prodSafe.html 文档 |
| 137 | 144 | // 适配:如果是本系统的管理员,则转换成 jimu 报表的管理员 |
| 138 | 145 | Long userId = SecurityFrameworkUtils.getLoginUserId(); | ... | ... |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/config/SecurityConfiguration.java
| 1 | 1 | package cn.iocoder.yudao.module.report.framework.security.config; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; |
| 4 | -import cn.iocoder.yudao.module.system.api.oauth2.OAuth2TokenApi; | |
| 5 | -import jakarta.annotation.Resource; | |
| 6 | 4 | import org.springframework.context.annotation.Bean; |
| 7 | 5 | import org.springframework.context.annotation.Configuration; |
| 8 | 6 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
| ... | ... | @@ -14,16 +12,15 @@ import org.springframework.security.config.annotation.web.configurers.AuthorizeH |
| 14 | 12 | @Configuration("reportSecurityConfiguration") |
| 15 | 13 | public class SecurityConfiguration { |
| 16 | 14 | |
| 17 | - @Resource | |
| 18 | - private OAuth2TokenApi oauth2TokenApi; | |
| 19 | - | |
| 20 | 15 | @Bean("reportAuthorizeRequestsCustomizer") |
| 21 | 16 | public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { |
| 22 | 17 | return new AuthorizeRequestsCustomizer() { |
| 18 | + | |
| 23 | 19 | @Override |
| 24 | 20 | public void customize(AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry registry) { |
| 25 | 21 | registry.requestMatchers("/jmreport/**").permitAll(); // 积木报表 |
| 26 | 22 | } |
| 23 | + | |
| 27 | 24 | }; |
| 28 | 25 | } |
| 29 | 26 | ... | ... |