-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[chance0523-issue32] jwt 구현 #35
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
예제 코드라 사실 제가 리뷰할 다른 부분이 바로 보이지는 않네요 🤣
그래도 기간내에 최대한 적용하셔서 보기 좋은 것 같습니다 🥇
추가적으로 controller의 response json에 대한 테스트나, 추가하지 못하셨던 다양한 실패 케이스에 대해서 고려보시면 좋을 것 같아요 :)
String header = request.getHeader(HttpHeaders.AUTHORIZATION); | ||
|
||
String[] headers = header.split(" "); | ||
if (headers.length == 2 && headers[0].equals("Token") && StringUtils.hasText(headers[1])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이부분은 제가 예제 코드에서 예제로써 쉽게 풀어내려고 하드코딩했는데 조금 개선해보는것도 좋을 것 같아요 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵~!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트까지 완료하셔서 초록색을 보여주세요 !
마지막까지 ✅
@@ -33,12 +33,15 @@ | |||
|
|||
private final String image; | |||
|
|||
public static UserResponse createResponse(User user) { | |||
private final String accessToken; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JsonProperty("token")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 token이 api 스펙이었네요
수정했습니다 👍
//@Formatter:off | ||
@WebMvcTest({UserController.class, SecurityConfig.class, JwtAuthenticationEntryPoint.class, JwtAccessDeniedHandler.class}) | ||
//@Formatter:on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is @Formatter
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//@Formatter:off 얘와
//@Formatter:on 얘 사이에 있는 코드는
포맷팅이 되지 않습니다! (자동정렬 안 먹음)
* @author JeongJoon Seo | ||
*/ | ||
@Component | ||
public class JwtAccessDeniedHandler implements AccessDeniedHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
* @author JeongJoon Seo | ||
*/ | ||
@Component | ||
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Codecov Report
@@ Coverage Diff @@
## chance0523 #35 +/- ##
================================================
- Coverage 100.00% 94.44% -5.56%
- Complexity 17 28 +11
================================================
Files 10 16 +6
Lines 41 90 +49
Branches 0 1 +1
================================================
+ Hits 41 85 +44
- Misses 0 4 +4
- Partials 0 1 +1
Continue to review full report at Codecov.
|
/** | ||
* @author Jeongjoon Seo | ||
*/ | ||
@Configuration | ||
@EnableGlobalMethodSecurity(prePostEnabled = true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이건 어떤 역할을 하는 어노테이션인지 간략한 설명 부탁드립니다 (_ _)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 뭔가 인프런 강의 따라 치다가 들어간 것 같은데요...
https://ncucu.me/136
위 블로그를 참고해보면
- Spring Security는 Web기반의 Security 외에 Method Security 기능을 제공하는데
Method Security는 우리가 기존에 사용했던 SecurityConfig 설정이 적용되지 않는다.
- Method Security용 설정이 따로 필요한데 이때 사용하는것이 **@EnableGlobalMethodSecurity**이다.
- `prePostEnabled`은 @PreAuthorize, @PostAuthorize을 사용할 수 있게 해줍니다 (여기서는 사용하지 않았습니다)
이정도?로 정리할 수 있겠네요. 아마 지금은 EnableGlobalMethodSecurity의 기능을 쓰고 있지 않는 것 같아서 없어도 되는 코드 같기도 하네요 (어려운 Spring Security.. 정확히 설명을 못 드리겠습니다 ㅠ_ㅠ)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
후니님께서 리뷰를 너무 잘해주셔서 크게 드릴건 없는 것 같네요 수고하셨습니다.
String header = request.getHeader(HttpHeaders.AUTHORIZATION); | ||
|
||
String[] headers = header.split(" "); | ||
if (headers.length == 2 && headers[0].equals("Token") && StringUtils.hasText(headers[1])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
매직 리터럴이랑 매직 스트링을 따로 빼면 좋을 것 같아요 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 그렇겠네요 감사합니다 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Issue: #32
작업 내용
생성/변경 로직
개인 코멘트