|
@@ -16,7 +16,6 @@ import com.chelvc.framework.base.context.LoggingContextHolder;
|
|
|
import com.chelvc.framework.base.context.SessionContextHolder;
|
|
|
import com.chelvc.framework.base.util.HttpUtils;
|
|
|
import com.chelvc.framework.base.util.SpringUtils;
|
|
|
-import com.chelvc.framework.common.model.Result;
|
|
|
import com.chelvc.framework.common.util.AESUtils;
|
|
|
import com.chelvc.framework.common.util.ObjectUtils;
|
|
|
import com.chelvc.framework.common.util.StringUtils;
|
|
@@ -43,6 +42,7 @@ import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
|
|
import org.springframework.security.oauth2.core.OAuth2Error;
|
|
|
import org.springframework.security.oauth2.jwt.JwtDecoder;
|
|
|
import org.springframework.security.oauth2.jwt.NimbusJwtDecoder;
|
|
|
+import org.springframework.security.oauth2.server.resource.InvalidBearerTokenException;
|
|
|
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
|
|
|
import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter;
|
|
|
import org.springframework.security.web.AuthenticationEntryPoint;
|
|
@@ -89,9 +89,12 @@ public class OAuthConfigurer extends WebSecurityConfigurerAdapter {
|
|
|
public AuthenticationEntryPoint authenticationEntryPoint() {
|
|
|
return (request, response, e) -> {
|
|
|
LoggingContextHolder.warn(log, request, e);
|
|
|
- if (e instanceof OAuth2AuthenticationException) {
|
|
|
+ if (e instanceof InvalidBearerTokenException) {
|
|
|
+ SessionContextHolder.response(response, "TOKEN_INVALID",
|
|
|
+ ApplicationContextHolder.getMessage("Token.Invalid"));
|
|
|
+ } else if (e instanceof OAuth2AuthenticationException) {
|
|
|
OAuth2Error error = ((OAuth2AuthenticationException) e).getError();
|
|
|
- SessionContextHolder.response(response, Result.of(error.getErrorCode(), null, error.getDescription()));
|
|
|
+ SessionContextHolder.response(response, error.getErrorCode(), error.getDescription());
|
|
|
} else {
|
|
|
SessionContextHolder.response(response, HttpStatus.FORBIDDEN, e.getMessage());
|
|
|
}
|