Commit 8204ccf6 authored by fangxinjiang's avatar fangxinjiang

鉴权-fxj

parent a18b87ea
...@@ -50,18 +50,18 @@ public class YifuWxLoginSuccessHandler implements AuthenticationSuccessHandler { ...@@ -50,18 +50,18 @@ public class YifuWxLoginSuccessHandler implements AuthenticationSuccessHandler {
@Override @Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
String header = request.getHeader(SecurityConstants.CLIENT_HEADER_KEY_NEW); /*String header = request.getHeader(SecurityConstants.CLIENT_HEADER_KEY_NEW);
if(Common.isEmpty(header)){ if(Common.isEmpty(header)){
header = request.getHeader(SecurityConstants.CLIENT_HEADER_KEY); header = request.getHeader(SecurityConstants.CLIENT_HEADER_KEY);
//兼容老逻辑 //兼容老逻辑
if(Common.isEmpty(header)){ if(Common.isEmpty(header)){
header = request.getHeader(HttpHeaders.AUTHORIZATION); header = request.getHeader(HttpHeaders.AUTHORIZATION);
} }
} }*/
YifuUser user = null; YifuUser user = null;
try { try {
user = (YifuUser)authentication.getPrincipal(); user = (YifuUser)authentication.getPrincipal();
if (header == null) { /*if (header == null) {
throw new InvalidClientException("请求头中client信息为空"); throw new InvalidClientException("请求头中client信息为空");
} }
String[] tokens = AuthUtils.extractAndDecodeHeader(header); String[] tokens = AuthUtils.extractAndDecodeHeader(header);
...@@ -73,9 +73,11 @@ public class YifuWxLoginSuccessHandler implements AuthenticationSuccessHandler { ...@@ -73,9 +73,11 @@ public class YifuWxLoginSuccessHandler implements AuthenticationSuccessHandler {
//校验secret //校验secret
if (!passwordEncoder.matches(tokens[1], clientDetails.getClientSecret())) { if (!passwordEncoder.matches(tokens[1], clientDetails.getClientSecret())) {
throw new InvalidClientException("请求头中client信息验证异常"); throw new InvalidClientException("请求头中client信息验证异常");
} }*/
TokenRequest tokenRequest = new TokenRequest(MapUtil.newHashMap(), clientId, clientDetails.getScope(), "password"); //TokenRequest tokenRequest = new TokenRequest(MapUtil.newHashMap(), clientId, clientDetails.getScope(), "password");
TokenRequest tokenRequest = new TokenRequest(MapUtil.newHashMap(), null,null, "password");
//校验scope //校验scope
ClientDetails clientDetails = clientDetailsService.loadClientByClientId(null);
new DefaultOAuth2RequestValidator().validateScope(tokenRequest, clientDetails); new DefaultOAuth2RequestValidator().validateScope(tokenRequest, clientDetails);
OAuth2Request oAuth2Request = tokenRequest.createOAuth2Request(clientDetails); OAuth2Request oAuth2Request = tokenRequest.createOAuth2Request(clientDetails);
OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(oAuth2Request, authentication); OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(oAuth2Request, authentication);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment