Repository navigation
[hotfix] #170 - 크로스사이트 재발급 오류 수정 #172
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
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
703cd87
fix: 인증 쿠키 발급/만료 처리 모두 SameSite=Strict에서 None으로 변경
Jy000n 70abcf4
feat: reissue, logout, withdraw 요청에 Origin 검증 필터 신규 추가
Jy000n fc475a0
fix: OriginValidationFilter가 기존 app.oauth2.allowed-frontend-urls 설정을 …
Jy000n 246706a
fix: SecurityConfig가 OriginValidationFilter를 생성자 주입으로 사용하도록 단순화
Jy000n 8e06063
fix: @Component 어노테이션 누락 추가
Jy000n 7e92932
fix: OriginValidationFilter의 서블릿 전역 필터 등록을 비활성화하여 SecurityConfig가 지정한…
Jy000n f3585b3
fix: CookieUtil이 secure 값에 따라 SameSite를 None/Strict로 분기하도록 수정
Jy000n 6ceb7c4
feat: 배포 환경 인증 쿠키에 CHIPS(Partitioned) 속성 추가
Jy000n e24644b
merge: develop 브랜치와 머지
Jy000n 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
41 changes: 41 additions & 0 deletions
41
src/main/java/com/Timo/Timo/global/auth/filter/OriginValidationFilter.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,41 @@ | ||
| package com.Timo.Timo.global.auth.filter; | ||
|
|
||
| import jakarta.servlet.FilterChain; | ||
| import jakarta.servlet.ServletException; | ||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import jakarta.servlet.http.HttpServletResponse; | ||
| import java.io.IOException; | ||
| import java.util.List; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.web.filter.OncePerRequestFilter; | ||
|
|
||
| @Component | ||
| public class OriginValidationFilter extends OncePerRequestFilter { | ||
|
|
||
| private static final List<String> PROTECTED_PATHS = List.of( | ||
| "/api/v1/auth/reissue", | ||
| "/api/v1/auth/logout", | ||
| "/api/v1/auth/withdraw" | ||
| ); | ||
|
|
||
| @Value("${app.oauth2.allowed-frontend-urls}") | ||
| private List<String> allowedFrontendUrls; | ||
|
|
||
| @Override | ||
| protected void doFilterInternal( | ||
| HttpServletRequest request, HttpServletResponse response, FilterChain filterChain | ||
| ) throws ServletException, IOException { | ||
| String path = request.getRequestURI(); | ||
|
|
||
| if (PROTECTED_PATHS.stream().anyMatch(path::equals)) { | ||
| String origin = request.getHeader("Origin"); | ||
| if (origin == null || !allowedFrontendUrls.contains(origin)) { | ||
| response.setStatus(HttpServletResponse.SC_FORBIDDEN); | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| filterChain.doFilter(request, response); | ||
| } | ||
| } | ||
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
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.
p3) @component 필터를 addFilterBefore에도 추가하면 컨테이너와 Spring Security가 각각 등록할 수 있습니다. Spring Security도 이 경우 이중 실행 또는 예상과 다른 순서가 발생할 수 있다고 명시합니다. Spring Security 공식 문서
아래처럼 MdcLoggingFilter와 동일하게 전역 등록을 비활성화해야 합니다.
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.
안 그래도 관련해서 코드래빗 리뷰를 받아서 해당 부분 반영하여 푸시하였었습니당