获取请求token方法移至权限工具类

This commit is contained in:
RuoYi
2020-11-30 15:09:59 +08:00
committed by 疯狂的狮子li
parent 7f1f9f368a
commit a29bb0bc51
4 changed files with 34 additions and 14 deletions

View File

@@ -35,6 +35,11 @@ public class FeignRequestInterceptor implements RequestInterceptor
{
requestTemplate.header(CacheConstants.DETAILS_USERNAME, userName);
}
String authentication = headers.get(CacheConstants.AUTHORIZATION_HEADER);
if (StringUtils.isNotEmpty(authentication))
{
requestTemplate.header(CacheConstants.AUTHORIZATION_HEADER, authentication);
}
}
}
}

View File

@@ -9,6 +9,7 @@ import org.springframework.stereotype.Component;
import com.ruoyi.common.core.constant.CacheConstants;
import com.ruoyi.common.core.constant.Constants;
import com.ruoyi.common.core.utils.IdUtils;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.common.core.utils.ServletUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.ip.IpUtils;
@@ -71,7 +72,7 @@ public class TokenService
public LoginUser getLoginUser(HttpServletRequest request)
{
// 获取请求携带的令牌
String token = getToken(request);
String token = SecurityUtils.getToken(request);
if (StringUtils.isNotEmpty(token))
{
String userKey = getTokenKey(token);
@@ -119,17 +120,4 @@ public class TokenService
{
return ACCESS_TOKEN + token;
}
/**
* 获取请求token
*/
private String getToken(HttpServletRequest request)
{
String token = request.getHeader(CacheConstants.HEADER);
if (StringUtils.isNotEmpty(token) && token.startsWith(CacheConstants.TOKEN_PREFIX))
{
token = token.replace(CacheConstants.TOKEN_PREFIX, "");
}
return token;
}
}