-
Notifications
You must be signed in to change notification settings - Fork 0
[fix] 비로그인 상태 비밀번호 재설정 엔드포인트 인증 제외 #93
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
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/main/java/com/daramg/server/auth/application/AsyncMailSender.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package com.daramg.server.auth.application; | ||
|
|
||
| import com.daramg.server.auth.domain.MailMessages; | ||
| import com.daramg.server.auth.util.MailContentBuilder; | ||
| import com.daramg.server.auth.util.MimeMessageGenerator; | ||
| import jakarta.mail.internet.MimeMessage; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.mail.javamail.JavaMailSender; | ||
| import org.springframework.scheduling.annotation.Async; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Slf4j | ||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class AsyncMailSender { | ||
|
|
||
| private final JavaMailSender javaMailSender; | ||
| private final MimeMessageGenerator mimeMessageGenerator; | ||
| private final MailContentBuilder mailContentBuilder; | ||
|
|
||
| @Async("mailTaskExecutor") | ||
| public void sendVerificationCode(String email, String verificationCode) { | ||
| try { | ||
| String htmlContent = mailContentBuilder.buildVerificationEmail(verificationCode); | ||
| MimeMessage mimeMessage = mimeMessageGenerator.generate( | ||
| email, | ||
| MailMessages.MAIL_VERIFICATION_SUBJECT, | ||
| htmlContent | ||
| ); | ||
| javaMailSender.send(mimeMessage); | ||
| } catch (Exception e) { | ||
| log.error("이메일 발송 실패 - email: {}, error: {}", email, e.getMessage()); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/daramg/server/common/config/AsyncConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.daramg.server.common.config; | ||
|
|
||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.scheduling.annotation.EnableAsync; | ||
| import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
|
|
||
| import java.util.concurrent.Executor; | ||
|
|
||
| @Configuration | ||
| @EnableAsync | ||
| public class AsyncConfig { | ||
|
|
||
| @Bean(name = "mailTaskExecutor") | ||
| public Executor mailTaskExecutor() { | ||
| ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | ||
| executor.setCorePoolSize(2); | ||
| executor.setMaxPoolSize(5); | ||
| executor.setQueueCapacity(100); | ||
| executor.setThreadNamePrefix("mail-"); | ||
| executor.initialize(); | ||
| return executor; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
A critical security concern exists here: the user's email address is logged in plain text when email sending fails. Email addresses are Personally Identifiable Information (PII) and should not be logged to avoid privacy violations and compliance issues (e.g., GDPR).
Additionally, while asynchronous processing improves API response time, the current implementation logs exceptions on email sending failure without proper handling. This means the API might return a 200 OK even if the email wasn't sent, potentially confusing users. Furthermore, the current logging only captures
e.getMessage(), missing the full stack trace needed for debugging. It's recommended to log the fullThrowabledirectly for better error context.