66 lines
3.2 KiB
Java
66 lines
3.2 KiB
Java
package com.jingyi.iotserver.clientmanage;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
@Configuration
|
|
public class InterceptorConfig implements WebMvcConfigurer {
|
|
@Autowired
|
|
LoginInterceptor loginInterceptor;
|
|
|
|
@Override
|
|
public void addInterceptors(InterceptorRegistry registry) {
|
|
InterceptorRegistration registration = registry.addInterceptor(loginInterceptor);
|
|
//addPathPatterns 用于添加拦截规则
|
|
//excludePathPatterns用于排除拦截规则
|
|
|
|
registration.addPathPatterns("/common/client/**");
|
|
registration.addPathPatterns("/firectrl/client/**");
|
|
registration.addPathPatterns("/firectrl/partner/**");
|
|
registration.addPathPatterns("/user/**");
|
|
registration.excludePathPatterns("/common/client/user/login");
|
|
registration.excludePathPatterns("/common/client/exit");
|
|
registration.excludePathPatterns("/common/client/user/saveoperate");
|
|
|
|
registration.excludePathPatterns("/firectrl/file/**");
|
|
registration.excludePathPatterns("/firectrl/partner/assign");
|
|
registration.excludePathPatterns("/firectrl/partner/getsensorcount");
|
|
registration.excludePathPatterns("/firectrl/partner/getsensorpage");
|
|
registration.excludePathPatterns("/firectrl/client/isactive");
|
|
registration.excludePathPatterns("/firectrl/client/user/login");
|
|
registration.excludePathPatterns("/firectrl/client/user/agentlogin");
|
|
registration.excludePathPatterns("/firectrl/client/test/db");
|
|
registration.excludePathPatterns("/iotserver/sensor/huaxtent/earthinductor");
|
|
registration.excludePathPatterns("/iotserver/sensor/**");
|
|
registration.excludePathPatterns("/iotserver/alarmtask/**");
|
|
registration.excludePathPatterns("/iotserver/pluginfo/**");
|
|
registration.excludePathPatterns("/firectrl/client/notice/sendmqtt");
|
|
registration.excludePathPatterns("/firectrl/client/map/**");
|
|
|
|
// registration.excludePathPatterns("/firectrl/client/getstationcount");
|
|
// registration.excludePathPatterns("/firectrl/client/user/create");
|
|
/* */
|
|
}
|
|
|
|
@Override
|
|
public void addCorsMappings(CorsRegistry registry) {
|
|
registry.addMapping("/**")
|
|
.allowedOrigins("*")
|
|
.allowedMethods("GET", "POST", "OPTION", "PUT")
|
|
.allowedHeaders("Content-Type", "X-Requested-With", "accept", "Origin", "Access-Control-Request-Method",
|
|
"Access-Control-Request-Headers","Authorization")
|
|
.allowCredentials(true)
|
|
.maxAge(3600);
|
|
/*
|
|
.exposedHeaders("Access-Control-Allow-Origin", "Access-Control-Allow-Credentials")
|
|
.allowedHeaders("*")
|
|
.exposedHeaders("Access-Control-Allow-Origin", "Access-Control-Allow-Credentials","sessionjy")
|
|
*/
|
|
}
|
|
|
|
}
|