package com.kxs.adminap.config;

 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.kxs.adminap.filter.JWTFilter;
 
/**
 * 过滤器配置
 *
 * @author kou
 */
@Configuration
public class FilterConfig {
 
    @Autowired
    private JWTFilter jwtFilter;
 
    @Bean
    public FilterRegistrationBean registrationBean() {
 
        FilterRegistrationBean registration = new FilterRegistrationBean();
        // 设置过滤器
        registration.setFilter(jwtFilter);
        // 设置拦截路径
        registration.addUrlPatterns("/api/*");
        // 设置过滤器名称
        registration.setName("JWTFilter");
        // 设置过滤器执行顺序
        registration.setOrder(1);
 
        return registration;
    }
}