token 발급시, 요청 파라미터 파일로깅 추가.
This commit is contained in:
@@ -242,6 +242,9 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
|
|||||||
log.setResultMessage(resultMessage);
|
log.setResultMessage(resultMessage);
|
||||||
log.setAccessToken(accessToken); // Add access token value to the log
|
log.setAccessToken(accessToken); // Add access token value to the log
|
||||||
|
|
||||||
|
logger.info("Token request[/oauth/token or /oauth2/token] => clientId: {}, grantType: {}, scope: {}",
|
||||||
|
clientId, data.getGrantType(), data.getScope());
|
||||||
|
|
||||||
tokenIssuanceLogDAO.saveTokenIssuanceLog(log);
|
tokenIssuanceLogDAO.saveTokenIssuanceLog(log);
|
||||||
} catch (Throwable th) {
|
} catch (Throwable th) {
|
||||||
logger.error("Error while logging token issuance: " + th.getMessage(), th);
|
logger.error("Error while logging token issuance: " + th.getMessage(), th);
|
||||||
|
|||||||
@@ -41,8 +41,14 @@ public class BearerTokenContoller {
|
|||||||
JSONObject resObject = new JSONObject();
|
JSONObject resObject = new JSONObject();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String clientId = req.getFirst("client_id"); // .get("client_id");
|
String clientId = req.getFirst("client_id");
|
||||||
String grantType = req.getFirst("grant_type");
|
String grantType = req.getFirst("grant_type");
|
||||||
|
String clientSecret = req.getFirst("client_secret");
|
||||||
|
String scopes = req.getFirst("scope");
|
||||||
|
|
||||||
|
logger.info("Token request[/auth/oauth/v2/token] => clientId: {}, grantType: {}, scope: {}",
|
||||||
|
clientId, grantType, scopes);
|
||||||
|
|
||||||
if (!StringUtils.equals(grantType, "client_credentials") ) {
|
if (!StringUtils.equals(grantType, "client_credentials") ) {
|
||||||
throw new JwtAuthException("unsupported_grant_type", "Unsupported grant type");
|
throw new JwtAuthException("unsupported_grant_type", "Unsupported grant type");
|
||||||
}
|
}
|
||||||
@@ -53,8 +59,10 @@ public class BearerTokenContoller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String tokenType = "Bearer";
|
String tokenType = "Bearer";
|
||||||
String clientSecret = req.getFirst("client_secret");
|
|
||||||
String scopes = req.getFirst("scope");
|
|
||||||
|
|
||||||
|
|
||||||
Long expiresIn = Long.valueOf(clientDetails.getAccessTokenValiditySeconds());
|
Long expiresIn = Long.valueOf(clientDetails.getAccessTokenValiditySeconds());
|
||||||
|
|
||||||
String[] reqScopeArr = org.springframework.util.StringUtils.tokenizeToStringArray(scopes, " ");
|
String[] reqScopeArr = org.springframework.util.StringUtils.tokenizeToStringArray(scopes, " ");
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ public class KjbMGOAuth2Controller {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private TokenIssuanceLogDAO tokenIssuanceLogDAO;
|
private TokenIssuanceLogDAO tokenIssuanceLogDAO;
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "/mapi/oauth2/token", method = RequestMethod.POST, produces = "application/json; charset=\"UTF-8\"")
|
@RequestMapping(value = "/mapi/oauth2/token", method = RequestMethod.POST, produces = "application/json; charset=\"UTF-8\"")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity<String> token(@RequestBody KjbMGOAuth2AccessTokenRequest tokenRequest,
|
public ResponseEntity<String> token(@RequestBody KjbMGOAuth2AccessTokenRequest tokenRequest,
|
||||||
@@ -78,8 +79,12 @@ public class KjbMGOAuth2Controller {
|
|||||||
String grantType = tokenRequest.getGrantType();
|
String grantType = tokenRequest.getGrantType();
|
||||||
String clientId = tokenRequest.getClientId();
|
String clientId = tokenRequest.getClientId();
|
||||||
String clientSecret = tokenRequest.getClientSecret();
|
String clientSecret = tokenRequest.getClientSecret();
|
||||||
|
String scopes = tokenRequest.getScope();
|
||||||
|
|
||||||
String[] scopeArr = org.springframework.util.StringUtils.tokenizeToStringArray(tokenRequest.getScope(), " ");
|
logger.info("Token request[/mapi/oauth2/token] => clientId: {}, grantType: {}, scope: {}",
|
||||||
|
clientId, grantType, scopes);
|
||||||
|
|
||||||
|
String[] scopeArr = org.springframework.util.StringUtils.tokenizeToStringArray(scopes, " ");
|
||||||
Set<String> scopeSet = new HashSet<String>();
|
Set<String> scopeSet = new HashSet<String>();
|
||||||
for (String scope : scopeArr) {
|
for (String scope : scopeArr) {
|
||||||
scopeSet.add(scope);
|
scopeSet.add(scope);
|
||||||
|
|||||||
Reference in New Issue
Block a user