Merge branch 'master' of gitee.com:youlaiorg/youlai-boot
This commit is contained in:
@@ -23,6 +23,7 @@ import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.ProviderManager;
|
||||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
||||
import jakarta.servlet.DispatcherType;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
|
||||
@@ -60,6 +61,8 @@ public class SecurityConfig {
|
||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||
return http
|
||||
.authorizeHttpRequests(requestMatcherRegistry -> {
|
||||
// ASYNC 调度请求(如 SSE emitter.send())不经过外部 HTTP 请求,没有 Authorization 头,直接放行
|
||||
requestMatcherRegistry.dispatcherTypeMatchers(DispatcherType.ASYNC).permitAll();
|
||||
String[] ignoreUrls = securityProperties.getIgnoreUrls();
|
||||
if (ArrayUtil.isNotEmpty(ignoreUrls)) {
|
||||
requestMatcherRegistry.requestMatchers(ignoreUrls).permitAll();
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.context.request.async.AsyncRequestTimeoutException;
|
||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||
import org.springframework.web.servlet.NoHandlerFoundException;
|
||||
import tools.jackson.core.JacksonException;
|
||||
@@ -174,6 +175,13 @@ public class GlobalExceptionHandler {
|
||||
return Result.failed(e.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(AsyncRequestTimeoutException.class)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public <T> Result<T> handleAsyncRequestTimeoutException(AsyncRequestTimeoutException e) {
|
||||
log.debug("SSE 异步请求超时");
|
||||
return null;
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
public <T> Result<T> handleException(Exception e) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user