Skip to content

Commit

Permalink
Merge pull request #80 from hook-killer/refactor/clean-log
Browse files Browse the repository at this point in the history
[refactor] 백엔드 이슈수정 및 코드정리중
  • Loading branch information
kwchoi11 authored Oct 24, 2023
2 parents 6f3fe27 + 779b270 commit b70111d
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class KakaoOauthHelper {
private final OIDCHelper oidcHelper;

public KakaoTokenResponse getOauthToken(String code, String referer) {
log.info("referer 1 : {}", referer);
return kakaoOauthClient.kakaoAuth(
kakaoOauthProperties.getKakaoClientId(),
referer ,
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/HookKiller/server/auth/helper/OIDCHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,13 @@ public class OIDCHelper {
private final JwtOIDCProvider jwtOIDCProvider;

private String getKidFromUnsignedIdToken(String token, String iss, String aud) {
log.info("getKidFromUnsignedIdToken 들어옴! token : {}", token);
log.info("getKidFromUnsignedTokenHeader의 반환값 : {}", jwtOIDCProvider.getKidFromUnsignedTokenHeader(token, iss, aud));
return jwtOIDCProvider.getKidFromUnsignedTokenHeader(token, iss, aud);
}

public OIDCDto getPayloadFromIdToken(
String token, String iss, String aud, OIDCResponse oidcResponse) {
log.info("getPayloadFromIdToken 들어옴! token : {}, iss : {}, aud : {}", token, iss, aud);
String kid = getKidFromUnsignedIdToken(token, iss, aud);

log.info("kid = {}", kid);

OIDCPublicKeyDto oidcPublicKeyDto =
oidcResponse.getKeys().stream()
.filter(o -> o.getKid().equals(kid))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public CommonBooleanResultResponse isUserArticleLike(Long articleId) {
boolean result = articleLikeRepository.findByArticleAndUser(article, user).isPresent();

log.info("IsUserArticleLike 조회 유저 >>> {} , 조회 요청 ArticleId >>> {}", user.getEmail(), article.getId());

return CommonBooleanResultResponse.builder()
.result(result)
.message(result ? ArticleLikeConstants.EXISTS_ARTICLE_LIKE : ArticleLikeConstants.NOT_EXISTS_ARTICLE_LIKE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public class ReplyService {
public void createReply(PostReplyRequestDto requestDto) {
User user = userUtils.getUser();

log.error("requestDTO : {}", requestDto.toString());
Reply reply = replyRepository.save(
Reply.builder()
.replyStatus(USABLE)
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/HookKiller/server/common/AbstractTimeStamp.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public abstract class AbstractTimeStamp {
@CreatedDate
@JsonFormat(
shape = JsonFormat.Shape.STRING,
pattern = "yyyy-MM-dd hh:mm:ss")
pattern = "yyyy-MM-dd hh:mm:ss",
timezone = "Asia/Seoul"
)
private Timestamp createAt;

@Column(
Expand All @@ -34,6 +36,8 @@ public abstract class AbstractTimeStamp {
@LastModifiedDate
@JsonFormat(
shape = JsonFormat.Shape.STRING,
pattern = "yyyy-MM-dd hh:mm:ss")
pattern = "yyyy-MM-dd hh:mm:ss",
timezone = "Asia/Seoul"
)
private Timestamp updateAt;
}
1 change: 0 additions & 1 deletion src/main/java/HookKiller/server/common/util/UserUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public static Long getCurrentUserId() {
if (authentication == null) {
throw SecurityContextNotFoundException.EXCEPTION;
}
log.info("principal : {}", authentication.getPrincipal().toString());
return Long.valueOf(authentication.getName());
}
public User getUser() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint {
@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
AuthenticationException authException) throws IOException {
log.error("JwtAuthenticationEntryPoint 탐");

response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,17 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
log.info("request: {}gdgd", request.getHeader(HEADER_STRING));

// 토근을 가져옴
String header = request.getHeader(HEADER_STRING);
String authToken = null;

log.error("JWT HEADER : {}", header) ;
log.info("JWT HEADER : {}", header) ;
// Bearer token인 경우 JWT 토큰 유효성 검사 진행
// AuthenticationManager 역할을 함. -> 토큰이 인증되어있으면 필터로 보내서 context에 저장. 토큰이 인증되어있지 않다면 AuthenticationProvider로 보내어 인증하도록 함.
// token 검증이 되고 인증 정보가 존재하지 않는 경우 spring security 인증 정보 저장
if (header != null && header.startsWith(TOKEN_PREFIX) && !header.equalsIgnoreCase(TOKEN_PREFIX)) {
authToken = header.replace(TOKEN_PREFIX,"");
log.warn("AuthToken : {}", authToken);
log.info("AuthToken : {}", authToken);
try {
AccessTokenDetail accessTokenDetail = jwtTokenProvider.parseAccessToken(authToken);

Expand Down Expand Up @@ -79,7 +77,6 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
// Filter에서 제외할 URL 설정
@Override
protected boolean shouldNotFilter(HttpServletRequest request) throws ServletException {
jwtProperties.getExcludePath().forEach(path -> log.info("path: {}\n", path));
return jwtProperties.getExcludePath().stream().anyMatch(exclude -> exclude.equalsIgnoreCase(request.getServletPath()));
}
}
1 change: 0 additions & 1 deletion src/main/java/HookKiller/server/jwt/JwtOIDCProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class JwtOIDCProvider {

// 외부에서 돌릴 검증 로직
public String getKidFromUnsignedTokenHeader(String token, String iss, String aud) {
log.error("getKidFromUnsignedTokenHeader들어옴!");
return (String) getUnsignedTokenClaims(token, iss, aud).getHeader().get(KID);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ spring:
# 매번 data.sql 기반으로 업데이트 되기 떄문에 데이터 많이 추가해주세요~
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${hook.db.url}:${hook.db.port}/${hook.db.database}
url: jdbc:mysql://${hook.db.url}:${hook.db.port}/${hook.db.database}?serverTimezone=UTC&useLegacyDatetimeCode=false
username: ${hook.db.username}
password: ${hook.db.password}

0 comments on commit b70111d

Please sign in to comment.