| | |
| | | |
| | | import cn.dev33.satoken.interceptor.SaInterceptor; |
| | | import cn.dev33.satoken.stp.StpUtil; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.context.annotation.DependsOn; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
| | | |
| | |
| | | // 小程序域:StpLogic("mini"),与后台 StpUtil 完全隔离(密码仅后台有效) |
| | | registry.addInterceptor( |
| | | new SaInterceptor( |
| | | handle -> |
| | | MiniStpUtil.checkLogin())) |
| | | handle -> { |
| | | ServletRequestAttributes attributes = |
| | | (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); |
| | | HttpServletRequest request = |
| | | attributes == null ? null : attributes.getRequest(); |
| | | if (request != null && "OPTIONS".equalsIgnoreCase(request.getMethod())) { |
| | | return; |
| | | } |
| | | MiniStpUtil.checkLogin(); |
| | | })) |
| | | .addPathPatterns("/api/mini/**") |
| | | .excludePathPatterns("/api/mini/auth/login", "/api/mini/auth/phone-login") |
| | | .excludePathPatterns( |
| | | "/api/mini/auth/login", |
| | | "/api/mini/auth/phone-login", |
| | | "/api/mini/auth/official-oauth-url", |
| | | "/api/mini/auth/official-login", |
| | | "/api/mini/auth/official-bind-phone", |
| | | "/api/mini/appointments/shared/detail", |
| | | "/api/mini/appointments/shared/visitor-codes", |
| | | "/api/mini/appointments/shared/ticket-code") |
| | | .order(0); |
| | | |
| | | // 平台管理端:sys_user 账密 |