diff --git a/src/main/java/com/dispose/config/AuthConfigure.java b/src/main/java/com/dispose/interceptor/AuthConfigureFilter.java similarity index 90% rename from src/main/java/com/dispose/config/AuthConfigure.java rename to src/main/java/com/dispose/interceptor/AuthConfigureFilter.java index a0d58ae6..aaa63764 100644 --- a/src/main/java/com/dispose/config/AuthConfigure.java +++ b/src/main/java/com/dispose/interceptor/AuthConfigureFilter.java @@ -1,71 +1,70 @@ -package com.dispose.config; - -import com.dispose.common.AuthConfigValue; -import com.dispose.interceptor.TokenInterceptor; -import lombok.Getter; -import lombok.Setter; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.stereotype.Component; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -import javax.annotation.PostConstruct; -import java.util.Optional; - -/** - * The type Auth configure. - * - * @author - */ -@Getter -@Setter -@Component -@ConfigurationProperties(prefix = "auth") -@Configuration -public class AuthConfigure implements WebMvcConfigurer { - /** - * The Token timeout minute. - */ - private Long tokenTimeoutMinute; - - /** - * The Verify request token. - */ - private Boolean verifyRequestToken; - - /** - * Init global value. - */ - @PostConstruct - private void initGlobalValue() { - AuthConfigValue.TOKEN_EXPIRED_TIME_MS = - Optional.of(tokenTimeoutMinute * 60 * 1000).orElse((long) 30 * 60 * 1000); - AuthConfigValue.VERIFY_REQUEST_TOKEN = Optional.ofNullable(verifyRequestToken).orElse(true); - } - - /** - * Init auth interceptor token interceptor. - * - * @return the token interceptor - */ - @Bean - public TokenInterceptor initAuthInterceptor() { - return new TokenInterceptor(); - } - - /** - * Add interceptors. - * - * @param registry the registry - */ - @Override - public void addInterceptors(InterceptorRegistry registry) { - // 注册需要检查token的控制器接口 - registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/auth/logout"); - registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/manager/**"); - registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/task/**"); - registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/info/**"); - } -} +package com.dispose.interceptor; + +import com.dispose.common.AuthConfigValue; +import lombok.Getter; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import javax.annotation.PostConstruct; +import java.util.Optional; + +/** + * The type Auth configure. + * + * @author + */ +@Getter +@Setter +@Component +@ConfigurationProperties(prefix = "auth") +@Configuration +public class AuthConfigureFilter implements WebMvcConfigurer { + /** + * The Token timeout minute. + */ + private Long tokenTimeoutMinute; + + /** + * The Verify request token. + */ + private Boolean verifyRequestToken; + + /** + * Init global value. + */ + @PostConstruct + private void initGlobalValue() { + AuthConfigValue.TOKEN_EXPIRED_TIME_MS = + Optional.of(tokenTimeoutMinute * 60 * 1000).orElse((long) 30 * 60 * 1000); + AuthConfigValue.VERIFY_REQUEST_TOKEN = Optional.ofNullable(verifyRequestToken).orElse(true); + } + + /** + * Init auth interceptor token interceptor. + * + * @return the token interceptor + */ + @Bean + public TokenInterceptor initAuthInterceptor() { + return new TokenInterceptor(); + } + + /** + * Add interceptors. + * + * @param registry the registry + */ + @Override + public void addInterceptors(InterceptorRegistry registry) { + // 注册需要检查token的控制器接口 + registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/auth/logout"); + registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/manager/**"); + registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/task/**"); + registry.addInterceptor(initAuthInterceptor()).addPathPatterns("/info/**"); + } +}