Skip to content

Commit 3da599b

Browse files
authored
[DDING-000] SSE 비동기 전송 시 Spring Security AccessDeniedException 발생 문제 해결 (#337)
1 parent 7f713a1 commit 3da599b

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

src/main/java/ddingdong/ddingdongBE/common/config/SecurityConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import ddingdong.ddingdongBE.common.filter.JwtAuthenticationFilter;
88
import ddingdong.ddingdongBE.common.handler.CustomAccessDeniedHandler;
99
import ddingdong.ddingdongBE.common.handler.RestAuthenticationEntryPoint;
10+
import jakarta.servlet.DispatcherType;
1011
import org.springframework.context.annotation.Bean;
1112
import org.springframework.context.annotation.Configuration;
1213
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
@@ -32,6 +33,7 @@ public SecurityFilterChain filterChain(HttpSecurity http, JwtAuthService authSer
3233
throws Exception {
3334
http
3435
.authorizeHttpRequests(auth -> auth
36+
.dispatcherTypeMatchers(DispatcherType.ASYNC).permitAll()
3537
.requestMatchers(API_PREFIX + "/auth/**",
3638
API_PREFIX + "/events/**")
3739
.permitAll()

src/main/java/ddingdong/ddingdongBE/domain/feed/service/FacadeClubFeedServiceImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
import java.time.LocalDateTime;
2020
import java.util.List;
2121
import lombok.RequiredArgsConstructor;
22+
import lombok.extern.slf4j.Slf4j;
2223
import org.springframework.data.domain.Slice;
2324
import org.springframework.stereotype.Service;
2425
import org.springframework.transaction.annotation.Transactional;
2526

27+
@Slf4j
2628
@Service
2729
@RequiredArgsConstructor
2830
@Transactional(readOnly = true)
@@ -88,6 +90,7 @@ public MyFeedPageQuery getMyFeedPage(User user, int size, Long currentCursorId)
8890
private void checkVodProcessingJobAndNotify(Feed feed) {
8991
VodProcessingJob vodProcessingJob = vodProcessingJobService.findByVideoFeedId(feed.getId());
9092
if (vodProcessingJob != null && vodProcessingJob.isPossibleNotify()) {
93+
log.info("피드 생성이 뒤늦게 완료되어 알람 전송 {} : {}", feed.getClub().getName(), feed.getId());
9194
SseEvent<SseVodProcessingNotificationDto> sseEvent = SseEvent.of(
9295
"vod-processing",
9396
new SseVodProcessingNotificationDto(

src/main/java/ddingdong/ddingdongBE/domain/vodprocessing/service/FacadeVodProcessingJobServiceImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
import java.time.LocalDateTime;
1515
import java.util.Optional;
1616
import lombok.RequiredArgsConstructor;
17+
import lombok.extern.slf4j.Slf4j;
1718
import org.springframework.stereotype.Service;
1819
import org.springframework.transaction.annotation.Transactional;
1920

2021
@Service
2122
@Transactional(readOnly = true)
23+
@Slf4j
2224
@RequiredArgsConstructor
2325
public class FacadeVodProcessingJobServiceImpl implements FacadeVodProcessingJobService {
2426

@@ -40,6 +42,7 @@ public Long create(CreatePendingVodProcessingJobCommand command) {
4042
@Override
4143
@Transactional
4244
public void updateVodProcessingJobStatus(UpdateVodProcessingJobStatusCommand command) {
45+
log.info("vod상태 업데이트 메서드 호출 {} : {}", command.convertJobId(), command.status());
4346
VodProcessingJob vodProcessingJob = vodProcessingJobService.getByConvertJobId(command.convertJobId());
4447
vodProcessingJob.updateConvertJobStatus(command.status());
4548
checkVodProcessingJobStatus(vodProcessingJob);
@@ -54,10 +57,12 @@ private void checkVodProcessingJobStatus(VodProcessingJob vodProcessingJob) {
5457
private void checkExistingFeedAndNotify(VodProcessingJob vodProcessingJob) {
5558
Long entityId = vodProcessingJob.getFileMetaData().getEntityId();
5659
if(entityId == null) {
60+
log.info("현재 피드 업로드가 완료되지 않아 알림 보내지 않고 종료");
5761
return;
5862
}
5963
Optional<Feed> optionalFeed = feedService.findById(entityId);
6064
if (optionalFeed.isPresent()) {
65+
log.info("피드 업로드가 완료된 상태로, 알람 전송");
6166
SseEvent<SseVodProcessingNotificationDto> sseEvent = SseEvent.of(
6267
"vod-processing",
6368
new SseVodProcessingNotificationDto(

src/main/java/ddingdong/ddingdongBE/sse/service/SseConnectionService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void sendVodProcessingNotification(VodProcessingJob vodProcessingJob, Sse
6161
sseEmitter.send(SseEmitter.event()
6262
.name("sse")
6363
.data(data));
64-
log.debug("SSE Event sent to user {}: {}", sseId, "sse");
64+
log.info("SSE Event 사용자에게 전송완료 userid:{}: {}", sseId, "sse");
6565
} catch (IOException e) {
6666
log.error("Error sending SSE event to user: {}", sseId, e);
6767
sseEmitter.complete();

0 commit comments

Comments
 (0)