package org.dromara.member.config;

import lombok.RequiredArgsConstructor;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * JWT Web配置
 *
 * @author pengles
 */
@Configuration
@RequiredArgsConstructor
public class AppJwtWebConfig {
    private final AppJwtFilter appJwtFilter;

    @Bean
    public FilterRegistrationBean<AppJwtFilter> appJwtFilterRegistration() {
        FilterRegistrationBean<AppJwtFilter> bean = new FilterRegistrationBean<>();
        bean.setFilter(appJwtFilter);
        // 设置过滤路径
        bean.addUrlPatterns("/system/session/*", "/system/message/*", "/app/user/*", "/app/file/*");
        bean.setName("AppJwtFilter");
        // 设置优先级，越小越靠前
        bean.setOrder(10);
        return bean;
    }
}

