-
Notifications
You must be signed in to change notification settings - Fork 0
토큰 검사 추가 #81
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
토큰 검사 추가 #81
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,8 @@ | |||||||||||
| import com.example.FixLog.repository.post.PostRepository; | ||||||||||||
| import com.example.FixLog.repository.tag.TagRepository; | ||||||||||||
| import jakarta.transaction.Transactional; | ||||||||||||
| import org.springframework.security.core.Authentication; | ||||||||||||
| import org.springframework.security.core.context.SecurityContextHolder; | ||||||||||||
| import org.springframework.stereotype.Service; | ||||||||||||
| import org.springframework.web.multipart.MultipartFile; | ||||||||||||
|
|
||||||||||||
|
|
@@ -99,6 +101,8 @@ public void createPost(PostRequestDto postRequestDto){ | |||||||||||
|
|
||||||||||||
| // 이미지 파일 마크다운으로 변경 | ||||||||||||
| public String uploadImage(MultipartFile imageFile){ | ||||||||||||
| SecurityContextHolder.getContext().getAuthentication(); | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 인증 객체를 조회했지만 사용하지 않고 있습니다.
다음과 같이 수정하여 토큰 검증을 구현하세요: - SecurityContextHolder.getContext().getAuthentication();
+ Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+ if (authentication == null || !authentication.isAuthenticated()) {
+ throw new CustomException(ErrorCode.UNAUTHORIZED);
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
|
|
||||||||||||
| if (imageFile == null || imageFile.isEmpty()){ | ||||||||||||
| throw new CustomException(ErrorCode.IMAGE_UPLOAD_FAILED); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
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.
🛠️ Refactor suggestion
Import 추가는 적절하지만 토큰 검증 로직이 필요합니다.
Spring Security의 Authentication과 SecurityContextHolder를 import했지만, 실제 토큰 검증 로직이 구현되지 않았습니다.
🤖 Prompt for AI Agents