mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-31 08:14:18 +08:00
🐛 Fixing a bug. close #I5UYRO 不提供令牌请求接口建议统一返回自定义异常码 424
This commit is contained in:
parent
5d0e38ab0d
commit
15a852761a
@ -24,6 +24,7 @@ import lombok.SneakyThrows;
|
|||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.security.authentication.InsufficientAuthenticationException;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.oauth2.server.resource.InvalidBearerTokenException;
|
import org.springframework.security.oauth2.server.resource.InvalidBearerTokenException;
|
||||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||||
@ -60,7 +61,8 @@ public class ResourceAuthExceptionEntryPoint implements AuthenticationEntryPoint
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 针对令牌过期返回特殊的 424
|
// 针对令牌过期返回特殊的 424
|
||||||
if (authException instanceof InvalidBearerTokenException) {
|
if (authException instanceof InvalidBearerTokenException
|
||||||
|
|| authException instanceof InsufficientAuthenticationException) {
|
||||||
response.setStatus(org.springframework.http.HttpStatus.FAILED_DEPENDENCY.value());
|
response.setStatus(org.springframework.http.HttpStatus.FAILED_DEPENDENCY.value());
|
||||||
result.setMsg(this.messageSource.getMessage("OAuth2ResourceOwnerBaseAuthenticationProvider.tokenExpired",
|
result.setMsg(this.messageSource.getMessage("OAuth2ResourceOwnerBaseAuthenticationProvider.tokenExpired",
|
||||||
null, LocaleContextHolder.getLocale()));
|
null, LocaleContextHolder.getLocale()));
|
||||||
|
Loading…
Reference in New Issue
Block a user