package cn.lihu.jh.server.ecg; import cn.lihu.jh.framework.security.config.AuthorizeRequestsCustomizer; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; /** * 前端静态资源与 SPA 页面外壳的免登录规则。 * *
* JhWebSecurityConfigurerAdapter#filterChain: * .antMatchers(GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js").permitAll() ** * 因此下列请求会命中兜底规则 {@code anyRequest().authenticated()} 并返回 * {@code 401 账号未登录},表现为**浏览器白屏或掉线**: *
* / /user /dict /codegen /job /login /roomselect * /redirect /sso /social-login /403 /404 /500 * /calling-screen-big /calling-screen-room * /ecg/** /clinic/** /system/** /infra/** ** *
* 接口: /ecg/screen/big-screen-data、/ecg/queue/page、/ecg/call/next
* 页面: /ecg/queue、/ecg/room、/ecg/check-type
*
* 若此处放行 {@code /ecg/**},则**所有 ECG 接口都会变成免鉴权**,
* 属于严重的安全漏洞(未登录即可读写排队数据)。
* 精确路径在 Spring 中不会匹配带子路径的接口,因此是安全的。
*/
private static final String[] SPA_PAGE_PATTERNS = {
"/", "/index.html",
// 来自 remaining.ts 的顶层静态路由
"/user/**", "/dict/**", "/codegen/**", "/job/**",
"/login", "/roomselect",
"/redirect/**", "/sso", "/social-login",
"/403", "/404", "/500",
"/calling-screen-big", "/calling-screen-room",
// —— ECG 业务页:必须精确,禁止 /ecg/** ——
"/ecg/appointment", "/ecg/appointment-confirm", "/ecg/alter",
"/ecg/queue", "/ecg/roomselect",
"/ecg/doc/routine", "/ecg/doc/dev-ready", "/ecg/doc/dev-install",
"/ecg/dev-dismantle", "/ecg/dev-rent",
"/ecg/doctor/dev-data-entry",
"/ecg/job-statistic", "/ecg/dev-statistic",
"/ecg/room", "/ecg/roomstatus", "/ecg/dev-model",
"/ecg/device", "/ecg/check-type",
// —— 诊室页(接口 /clinic/room/* 带子路径,不冲突)——
"/clinic/room",
// —— 系统管理与基础设施页(其接口均位于 /admin-api 下,不冲突)——
"/system/**", "/infra/**",
};
@Override
public void customize(ExpressionUrlAuthorizationConfigurer