diff --git a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/ResourceAuthExceptionEntryPoint.java b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/ResourceAuthExceptionEntryPoint.java index 1a5aa694..7b6cffb6 100755 --- a/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/ResourceAuthExceptionEntryPoint.java +++ b/pig-common/pig-common-security/src/main/java/com/pig4cloud/pig/common/security/component/ResourceAuthExceptionEntryPoint.java @@ -24,6 +24,7 @@ import lombok.SneakyThrows; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.http.HttpStatus; +import org.springframework.security.authentication.InsufficientAuthenticationException; import org.springframework.security.core.AuthenticationException; import org.springframework.security.oauth2.server.resource.InvalidBearerTokenException; import org.springframework.security.web.AuthenticationEntryPoint; @@ -60,7 +61,8 @@ public class ResourceAuthExceptionEntryPoint implements AuthenticationEntryPoint } // 针对令牌过期返回特殊的 424 - if (authException instanceof InvalidBearerTokenException) { + if (authException instanceof InvalidBearerTokenException + || authException instanceof InsufficientAuthenticationException) { response.setStatus(org.springframework.http.HttpStatus.FAILED_DEPENDENCY.value()); result.setMsg(this.messageSource.getMessage("OAuth2ResourceOwnerBaseAuthenticationProvider.tokenExpired", null, LocaleContextHolder.getLocale()));