diff --git a/continew-starter-auth/continew-starter-auth-satoken/src/main/java/top/continew/starter/auth/satoken/autoconfigure/SaTokenAutoConfiguration.java b/continew-starter-auth/continew-starter-auth-satoken/src/main/java/top/continew/starter/auth/satoken/autoconfigure/SaTokenAutoConfiguration.java index b5f46f9c..c277473a 100644 --- a/continew-starter-auth/continew-starter-auth-satoken/src/main/java/top/continew/starter/auth/satoken/autoconfigure/SaTokenAutoConfiguration.java +++ b/continew-starter-auth/continew-starter-auth-satoken/src/main/java/top/continew/starter/auth/satoken/autoconfigure/SaTokenAutoConfiguration.java @@ -36,6 +36,7 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import top.continew.starter.auth.satoken.autoconfigure.dao.SaTokenDaoConfiguration; +import top.continew.starter.core.constant.OrderedConstants; import top.continew.starter.core.constant.PropertiesConstants; import top.continew.starter.core.constant.StringConstants; import top.continew.starter.core.util.GeneralPropertySourceFactory; @@ -61,7 +62,9 @@ public class SaTokenAutoConfiguration implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(SpringUtil.getBean(SaInterceptor.class)).addPathPatterns(StringConstants.PATH_PATTERN); + registry.addInterceptor(SpringUtil.getBean(SaInterceptor.class)) + .addPathPatterns(StringConstants.PATH_PATTERN) + .order(OrderedConstants.Interceptor.AUTH_INTERCEPTOR); } /** diff --git a/continew-starter-core/src/main/java/top/continew/starter/core/constant/OrderedConstants.java b/continew-starter-core/src/main/java/top/continew/starter/core/constant/OrderedConstants.java new file mode 100644 index 00000000..1ea1f239 --- /dev/null +++ b/continew-starter-core/src/main/java/top/continew/starter/core/constant/OrderedConstants.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *
+ * http://www.gnu.org/licenses/lgpl.html + *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package top.continew.starter.core.constant;
+
+import org.springframework.core.Ordered;
+
+/**
+ * 过滤器和拦截器相关顺序常量
+ *
+ * @author Charles7c
+ * @since 2.13.3
+ */
+public class OrderedConstants {
+
+ /**
+ * 过滤器顺序
+ */
+ public static final class Filter {
+
+ /**
+ * 链路追踪过滤器顺序
+ */
+ public static final int TRACE_FILTER = Ordered.HIGHEST_PRECEDENCE + 100;
+
+ /**
+ * XSS 过滤器顺序
+ */
+ public static final int XSS_FILTER = Ordered.HIGHEST_PRECEDENCE + 200;
+
+ /**
+ * 日志过滤器顺序
+ */
+ public static final int LOG_FILTER = Ordered.LOWEST_PRECEDENCE - 100;
+
+ private Filter() {
+ }
+ }
+
+ /**
+ * 拦截器顺序
+ */
+ public static final class Interceptor {
+
+ /**
+ * 租户拦截器顺序
+ */
+ public static final int TENANT_INTERCEPTOR = Ordered.HIGHEST_PRECEDENCE + 100;
+
+ /**
+ * 认证拦截器顺序
+ */
+ public static final int AUTH_INTERCEPTOR = Ordered.HIGHEST_PRECEDENCE + 200;
+
+ /**
+ * 日志拦截器顺序
+ */
+ public static final int LOG_INTERCEPTOR = Ordered.LOWEST_PRECEDENCE - 100;
+
+ private Interceptor() {
+ }
+ }
+
+ private OrderedConstants() {
+ }
+}
\ No newline at end of file
diff --git a/continew-starter-extension/continew-starter-extension-tenant/continew-starter-extension-tenant-core/src/main/java/top/continew/starter/extension/tenant/autoconfigure/TenantWebMvcAutoConfiguration.java b/continew-starter-extension/continew-starter-extension-tenant/continew-starter-extension-tenant-core/src/main/java/top/continew/starter/extension/tenant/autoconfigure/TenantWebMvcAutoConfiguration.java
index 58ba0cda..5d359310 100644
--- a/continew-starter-extension/continew-starter-extension-tenant/continew-starter-extension-tenant-core/src/main/java/top/continew/starter/extension/tenant/autoconfigure/TenantWebMvcAutoConfiguration.java
+++ b/continew-starter-extension/continew-starter-extension-tenant/continew-starter-extension-tenant-core/src/main/java/top/continew/starter/extension/tenant/autoconfigure/TenantWebMvcAutoConfiguration.java
@@ -19,9 +19,9 @@ package top.continew.starter.extension.tenant.autoconfigure;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import top.continew.starter.core.constant.OrderedConstants;
import top.continew.starter.extension.tenant.annotation.ConditionalOnEnabledTenant;
import top.continew.starter.extension.tenant.config.TenantProvider;
import top.continew.starter.extension.tenant.interceptor.TenantInterceptor;
@@ -49,6 +49,6 @@ public class TenantWebMvcAutoConfiguration implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new TenantInterceptor(tenantProperties, tenantProvider))
- .order(Ordered.HIGHEST_PRECEDENCE);
+ .order(OrderedConstants.Interceptor.TENANT_INTERCEPTOR);
}
}
diff --git a/continew-starter-log/continew-starter-log-aop/src/main/java/top/continew/starter/log/autoconfigure/LogAutoConfiguration.java b/continew-starter-log/continew-starter-log-aop/src/main/java/top/continew/starter/log/autoconfigure/LogAutoConfiguration.java
index 00498a90..0e2a926c 100644
--- a/continew-starter-log/continew-starter-log-aop/src/main/java/top/continew/starter/log/autoconfigure/LogAutoConfiguration.java
+++ b/continew-starter-log/continew-starter-log-aop/src/main/java/top/continew/starter/log/autoconfigure/LogAutoConfiguration.java
@@ -22,8 +22,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import top.continew.starter.core.constant.OrderedConstants;
import top.continew.starter.log.annotation.ConditionalOnEnabledLog;
import top.continew.starter.log.aspect.AccessLogAspect;
import top.continew.starter.log.aspect.LogAspect;
@@ -61,8 +63,11 @@ public class LogAutoConfiguration {
*/
@Bean
@ConditionalOnMissingBean
- public LogFilter logFilter() {
- return new LogFilter(logProperties);
+ public FilterRegistrationBean