初始化提交
This commit is contained in:
+71
@@ -0,0 +1,71 @@
|
||||
package com.roomroot.jwgl.config;
|
||||
|
||||
import com.roomroot.jwgl.interceptor.AccountManagementAuthorizationInterceptor;
|
||||
import com.roomroot.jwgl.interceptor.OperationLogInterceptor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* 在线账户状态和账户管理权限 Web MVC 配置。
|
||||
*
|
||||
* <p>该配置对已有在线会话执行账户状态校验,同时保持普通匿名请求的原有访问规则;
|
||||
* 账户管理路径继续执行超级管理员权限校验,并在校验通过后采集操作日志上下文。</p>
|
||||
*/
|
||||
@Configuration
|
||||
public class AccountManagementWebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
/**
|
||||
* 账户管理身份和权限拦截器。
|
||||
*/
|
||||
private final AccountManagementAuthorizationInterceptor
|
||||
authorizationInterceptor;
|
||||
|
||||
/**
|
||||
* 操作日志统一请求采集拦截器。
|
||||
*/
|
||||
private final OperationLogInterceptor operationLogInterceptor;
|
||||
|
||||
/**
|
||||
* 构造账户管理和操作日志统一 Web MVC 配置。
|
||||
*
|
||||
* @param authorizationInterceptor 账户管理身份和权限拦截器
|
||||
* @param operationLogInterceptor 操作日志统一请求采集拦截器
|
||||
*/
|
||||
public AccountManagementWebMvcConfig(
|
||||
AccountManagementAuthorizationInterceptor
|
||||
authorizationInterceptor,
|
||||
OperationLogInterceptor operationLogInterceptor) {
|
||||
// 第一步:保存账户管理专用拦截器,供 MVC 注册阶段使用。
|
||||
this.authorizationInterceptor = authorizationInterceptor;
|
||||
|
||||
// 第二步:保存操作日志采集拦截器,供 MVC 注册阶段使用。
|
||||
this.operationLogInterceptor = operationLogInterceptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册账户状态校验、账户管理权限和操作日志采集规则。
|
||||
*
|
||||
* @param registry Spring MVC 拦截器注册器
|
||||
*/
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
/*
|
||||
* 第一步:注册账户管理鉴权拦截器。
|
||||
* 第二步:覆盖全部 Controller 请求,使停用或已合并账户不能绕过
|
||||
* 账户管理路径继续访问其他业务接口。
|
||||
* 第三步:拦截器内部会放行没有 Servlet 会话的普通匿名请求,
|
||||
* 因此不会改变项目现有公开接口的访问方式。
|
||||
*/
|
||||
// registry.addInterceptor(authorizationInterceptor)
|
||||
// .addPathPatterns("/**");
|
||||
|
||||
/*
|
||||
* 第四步:在账户状态和账户管理权限校验通过后采集日志上下文。
|
||||
* 第五步:覆盖全部 Controller 请求,由采集拦截器自行跳过
|
||||
* 非 Controller 处理器和没有有效登录记录的请求。
|
||||
*/
|
||||
registry.addInterceptor(operationLogInterceptor)
|
||||
.addPathPatterns("/**");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user