token 발급시, 요청 파라미터 파일로깅 추가.

This commit is contained in:
cho
2026-01-20 14:04:30 +09:00
parent 121389c267
commit f8d97734a4
3 changed files with 20 additions and 4 deletions
@@ -242,6 +242,9 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
log.setResultMessage(resultMessage);
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);
} catch (Throwable th) {
logger.error("Error while logging token issuance: " + th.getMessage(), th);
@@ -41,8 +41,14 @@ public class BearerTokenContoller {
JSONObject resObject = new JSONObject();
try {
String clientId = req.getFirst("client_id"); // .get("client_id");
String clientId = req.getFirst("client_id");
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") ) {
throw new JwtAuthException("unsupported_grant_type", "Unsupported grant type");
}
@@ -53,8 +59,10 @@ public class BearerTokenContoller {
}
String tokenType = "Bearer";
String clientSecret = req.getFirst("client_secret");
String scopes = req.getFirst("scope");
Long expiresIn = Long.valueOf(clientDetails.getAccessTokenValiditySeconds());
String[] reqScopeArr = org.springframework.util.StringUtils.tokenizeToStringArray(scopes, " ");
@@ -59,6 +59,7 @@ public class KjbMGOAuth2Controller {
@Autowired
private TokenIssuanceLogDAO tokenIssuanceLogDAO;
@RequestMapping(value = "/mapi/oauth2/token", method = RequestMethod.POST, produces = "application/json; charset=\"UTF-8\"")
@ResponseBody
public ResponseEntity<String> token(@RequestBody KjbMGOAuth2AccessTokenRequest tokenRequest,
@@ -78,8 +79,12 @@ public class KjbMGOAuth2Controller {
String grantType = tokenRequest.getGrantType();
String clientId = tokenRequest.getClientId();
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>();
for (String scope : scopeArr) {
scopeSet.add(scope);