Skip to content

Commit

Permalink
Fix: test api 수정 및 jwt 에러 수정 (#72)
Browse files Browse the repository at this point in the history
* Refacor: jwt error response 세분화
토큰 만료, 유효하지 않은 토큰, 지원하지 않는 토큰 추가

* Refactor: global exceptioin 추가
exception 추가 및 주석 추가

* Fix: test api 수정 및 jwt 에러 수정
jwt error에서 사용하지 않는 uri에 대해 접근을 시도하면 UNAuthrized에러 나오게끔 변경

#70
  • Loading branch information
wcorn authored Jan 7, 2024
1 parent f2263b3 commit bd17c8e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public class SecurityConfig {
private final String[] GET_PERMITTED_URLS = {
"/api/swagger-ui/**", "/api/swagger-resources/**",
"/api/v3/api-docs/**", "/api/auth/kakao", "/api/auth/refresh", "/api/auth/logout", "/api/auth/logout",
"/api/test/success", "/api/test/fail",
"/api/posts","/api/posts/*", "/api/posts/*/download", "/api/posts/fubao/love"
};
private final String[] POST_PERMITTED_URLS = {
"/api/posts/fubao/love"
"/api/posts/fubao/love",
"/api/test/success", "/api/test/fail"
};
@Value("${security.cors-urls}")
private final List<String> CORS_URLS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ private void setResponse(HttpServletResponse response, ResponseCode responseCode
response.setStatus(HttpStatus.UNAUTHORIZED.value());
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
if(responseCode==null)
responseCode = ResponseCode.UNAUTHORIZED;
objectMapper.writeValue(response.getWriter(), ResponseEntity.status(responseCode.getStatus()).body(ErrorResponse.of(responseCode)));
}
}

0 comments on commit bd17c8e

Please sign in to comment.