“mitao”
2026-02-11 504880873eeea15bcbe7d5a79608ccc4abacb0d2
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
package com.estate.expert.admin.config;
 
import com.estate.expert.admin.interceptor.SsoSessionInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
/**
 * 拦截器配置
 * @Author code
 * @Description 拦截器配置
 * @Date 2023/2/26 11:42
 * @Version 1.0
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
 
    @Autowired
    private SsoSessionInterceptor ssoSessionInterceptor;
 
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(ssoSessionInterceptor)
                // 排除Swagger相关路径,允许匿名访问
                .excludePathPatterns("/swagger-ui/**")
                .excludePathPatterns("/webjars/**")
                .excludePathPatterns("/v3/api-docs/**")
                .excludePathPatterns("/swagger-resources/**")
                // 排除公共接口路径
                .excludePathPatterns("/public/**");
    }
 
}