Commit 03de176d authored by 陈炎's avatar 陈炎

🎨 log

parent a5de3362
...@@ -4,8 +4,9 @@ import cn.hutool.core.util.StrUtil; ...@@ -4,8 +4,9 @@ import cn.hutool.core.util.StrUtil;
import com.afanticar.afantiopenapi.controller.BaseController; import com.afanticar.afantiopenapi.controller.BaseController;
import com.afanticar.afantiopenapi.utils.JWTUtils; import com.afanticar.afantiopenapi.utils.JWTUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.HandlerInterceptor;
...@@ -18,17 +19,19 @@ import java.util.Set; ...@@ -18,17 +19,19 @@ import java.util.Set;
* @contact chenyan@afanticar.com * @contact chenyan@afanticar.com
* @since 2023/4/26/026 * @since 2023/4/26/026
*/ */
@Component
@Slf4j @Slf4j
@Setter
@Component
@ConfigurationProperties(prefix = "ignored")
public class TokenInterceptor implements HandlerInterceptor { public class TokenInterceptor implements HandlerInterceptor {
@Value("#{'${ignored.uri}'.split(',')}") private Set<String> uris;
private Set<String> ignoredUris;
@Override @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
String requestUri = request.getRequestURI(); String requestUri = request.getRequestURI();
if (ignoredUris.contains(requestUri)) { if (uris.contains(requestUri)) {
return true; return true;
} }
String token = request.getHeader("authorization"); String token = request.getHeader("authorization");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment