增加认证日志
This commit is contained in:
@@ -38,10 +38,7 @@ import java.security.Principal;
|
|||||||
import java.security.interfaces.RSAPublicKey;
|
import java.security.interfaces.RSAPublicKey;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hongawen
|
* @author hongawen
|
||||||
@@ -65,8 +62,6 @@ public class AuthController extends BaseController {
|
|||||||
private final UserTokenService userTokenService;
|
private final UserTokenService userTokenService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ApiIgnore
|
@ApiIgnore
|
||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.AUTHENTICATE)
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.AUTHENTICATE)
|
||||||
@ApiOperation("登录认证")
|
@ApiOperation("登录认证")
|
||||||
@@ -86,9 +81,10 @@ public class AuthController extends BaseController {
|
|||||||
String methodDescribe = getMethodDescribe("postAccessToken");
|
String methodDescribe = getMethodDescribe("postAccessToken");
|
||||||
String username = parameters.get(SecurityConstants.USERNAME);
|
String username = parameters.get(SecurityConstants.USERNAME);
|
||||||
String grantType = parameters.get(SecurityConstants.GRANT_TYPE);
|
String grantType = parameters.get(SecurityConstants.GRANT_TYPE);
|
||||||
|
log.error("登录参数为:" + parameters);
|
||||||
if (grantType.equalsIgnoreCase(SecurityConstants.GRANT_CAPTCHA)) {
|
if (grantType.equalsIgnoreCase(SecurityConstants.GRANT_CAPTCHA)) {
|
||||||
username = DesUtils.aesDecrypt(username);
|
username = DesUtils.aesDecrypt(username);
|
||||||
}else if(grantType.equalsIgnoreCase(SecurityConstants.GRANT_SMS_CODE)){
|
} else if (grantType.equalsIgnoreCase(SecurityConstants.GRANT_SMS_CODE)) {
|
||||||
//短信方式登录,将手机号赋值为用户名
|
//短信方式登录,将手机号赋值为用户名
|
||||||
username = parameters.get(SecurityConstants.PHONE);
|
username = parameters.get(SecurityConstants.PHONE);
|
||||||
}
|
}
|
||||||
@@ -99,11 +95,11 @@ public class AuthController extends BaseController {
|
|||||||
RequestUtil.saveLoginName(username);
|
RequestUtil.saveLoginName(username);
|
||||||
OAuth2AccessToken oAuth2AccessToken = tokenEndpoint.postAccessToken(principal, parameters).getBody();
|
OAuth2AccessToken oAuth2AccessToken = tokenEndpoint.postAccessToken(principal, parameters).getBody();
|
||||||
//用户的登录名&密码校验成功后,判断当前该用户是否可以正常使用系统
|
//用户的登录名&密码校验成功后,判断当前该用户是否可以正常使用系统
|
||||||
if(!grantType.equalsIgnoreCase(SecurityConstants.GRANT_SMS_CODE)){
|
if (!grantType.equalsIgnoreCase(SecurityConstants.GRANT_SMS_CODE)) {
|
||||||
userFeignClient.judgeUserStatus(username);
|
userFeignClient.judgeUserStatus(username);
|
||||||
}
|
}
|
||||||
//登录成功后,记录token信息,并处理踢人效果
|
//登录成功后,记录token信息,并处理踢人效果
|
||||||
userTokenService.recordUserInfo(oAuth2AccessToken,RequestUtil.getRealIp());
|
userTokenService.recordUserInfo(oAuth2AccessToken, RequestUtil.getRealIp());
|
||||||
if (!grantType.equalsIgnoreCase(SecurityConstants.PASSWORD)) {
|
if (!grantType.equalsIgnoreCase(SecurityConstants.PASSWORD)) {
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, oAuth2AccessToken, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, oAuth2AccessToken, methodDescribe);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ public class CaptchaTokenGranter extends AbstractTokenGranter {
|
|||||||
userAuth = authenticationManager.authenticate(userAuth);
|
userAuth = authenticationManager.authenticate(userAuth);
|
||||||
} catch (AccountStatusException | BadCredentialsException ase) {
|
} catch (AccountStatusException | BadCredentialsException ase) {
|
||||||
//covers expired, locked, disabled cases
|
//covers expired, locked, disabled cases
|
||||||
|
ase.printStackTrace();
|
||||||
throw new InvalidGrantException(ase.getMessage());
|
throw new InvalidGrantException(ase.getMessage());
|
||||||
}
|
}
|
||||||
// If the username/password are wrong the spec says we should send 400/invalid grant
|
// If the username/password are wrong the spec says we should send 400/invalid grant
|
||||||
|
|||||||
Reference in New Issue
Block a user