提交 4d7dbb7b 编写于 作者: zlt2000's avatar zlt2000

fix url权限认证时租户id获取不到的问题

上级 b060d8ee
......@@ -3,6 +3,7 @@ package com.central.oauth2.common.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.central.common.constant.CommonConstant;
import com.central.common.context.TenantContextHolder;
import com.central.common.model.SysMenu;
import com.central.oauth2.common.properties.SecurityProperties;
import com.central.oauth2.common.service.IPermissionService;
......@@ -78,6 +79,10 @@ public abstract class DefaultPermissionServiceImpl implements IPermissionService
return false;
}
//保存租户信息
String clientId = auth2Authentication.getOAuth2Request().getClientId();
TenantContextHolder.setTenant(clientId);
String roleCodes = grantedAuthorityList.stream().map(SimpleGrantedAuthority::getAuthority).collect(Collectors.joining(", "));
List<SysMenu> menuList = findMenuByRoleCodes(roleCodes);
for (SysMenu menu : menuList) {
......
......@@ -26,6 +26,8 @@ public class TenantInterceptor implements HandlerInterceptor {
//保存租户id
if(StrUtil.isNotEmpty(tenantId)){
TenantContextHolder.setTenant(tenantId);
} else {
TenantContextHolder.clear();
}
return true;
}
......
package com.central;
import com.central.common.ribbon.annotation.EnableFeignInterceptor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
......@@ -11,6 +12,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
*/
@EnableZuulProxy
@EnableFeignClients
@EnableFeignInterceptor
@EnableDiscoveryClient
@SpringBootApplication
public class GatewayApp {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册