liujie
2026-04-03 199b087e97231bc602cd5ed8668f37d6f336dff4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.xiaopeng.common.security.config;
 
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.xiaopeng.common.security.interceptor.HeaderInterceptor;
 
/**
 * 拦截器配置
 *
 * @author ruoyi
 */
public class WebMvcConfig implements WebMvcConfigurer
{
    /** 不需要拦截地址 */
    public static final String[] excludeUrls = {
            "/login",
            "/logout",
            "/refresh",
            "/register",
            "/base/v1/login",
            "/base/v1/captcha",
            "/base/v1/operationPasswordLogin",
            "/base/v1/verificationCodeLogin",
            "/base/v1/getVerificationCode",
            "/base/v1/updatePassword"
    };
 
    @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
        registry.addInterceptor(getHeaderInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns(excludeUrls)
                .order(-10);
    }
 
    /**
     * 自定义请求头拦截器
     */
    public HeaderInterceptor getHeaderInterceptor()
    {
        return new HeaderInterceptor();
    }
}