yonge 5 年之前
父节点
当前提交
c8fb02ab67

+ 2 - 0
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/web/controller/TokenController.java

@@ -97,6 +97,8 @@ public class TokenController extends BaseController {
 		MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
 		params.add("refresh_token", refreshToken);
 		params.add("grant_type", "refresh_token");
+		params.add("client_id", clientId);
+		params.add("client_secret", clientSecret);
 
 		HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<MultiValueMap<String, String>>(params, headers);
 

+ 4 - 3
mec-common/common-core/src/main/java/com/ym/mec/common/security/BaseAuthenticationEntryPoint.java

@@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.springframework.http.MediaType;
+import org.springframework.security.authentication.InsufficientAuthenticationException;
 import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.oauth2.common.exceptions.InvalidTokenException;
 import org.springframework.security.web.AuthenticationEntryPoint;
@@ -27,14 +28,14 @@ public class BaseAuthenticationEntryPoint implements AuthenticationEntryPoint {
 		response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
 		response.setStatus(HttpServletResponse.SC_OK);
 		PrintWriter printWriter = response.getWriter();
-		
+
 		Throwable e = ExceptionUtils.getRootCause(authException);
 		if (e == null) {
 			e = authException;
 		}
-		
+
 		int errorCode = 500;
-		if(e instanceof InvalidTokenException){
+		if (e instanceof InvalidTokenException || e instanceof InsufficientAuthenticationException) {
 			errorCode = HttpServletResponse.SC_FORBIDDEN;
 		}