Skip to content

merge: (#1045) permitAll 경로를 SecurityConfig로 일원화 - #1046

Open
yellowstarr0323 wants to merge 2 commits into
developfrom
fix/1045-unify-permit-all-paths
Open

merge: (#1045) permitAll 경로를 SecurityConfig로 일원화#1046
yellowstarr0323 wants to merge 2 commits into
developfrom
fix/1045-unify-permit-all-paths

Conversation

@yellowstarr0323

@yellowstarr0323 yellowstarr0323 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

작업 내용 설명

  • 기존에 permit all 로 관리하던 것을 삭제하고 security config로 관리하도록 설정

주요 변경 사항

  • resolveToken() 메서드를 resolveTokenOrNull()로 수정하여 토큰이 null이면 null을 반환해서 401에러로 유도하도록 수정

체크리스트

  • 어플리케이션 구동(혹은 테스트)시 오류는 없나요?
  • 생성된 코드에 Javadoc 주석을 추가 하였나요?
  • 생성된 코드에 대한 테스트 코드가 작성 되었나요?

관련 이슈

Summary by CodeRabbit

  • 개선 사항
    • JWT가 없는 요청도 예외 없이 처리되어 비인증 상태로 계속 진행됩니다.
    • JWT가 제공된 경우에만 사용자 인증 정보가 설정됩니다.
    • 잘못된 토큰은 계속해서 유효하지 않은 토큰 오류로 처리됩니다.
    • 루트 경로(/)를 인증 없이 이용할 수 있습니다.
    • 인증 실패 오류 코드가 INVALID_TOKEN으로 변경되었습니다.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

JWT 필터가 Authorization 헤더가 없는 요청을 인증 없이 통과시킵니다. permit-all 경로 목록을 제거하고 루트 경로를 SecurityConfig에서 허용합니다. 인증 실패 코드를 INVALID_TOKEN으로 변경하고 관련 테스트를 통합했습니다.

Changes

인증 및 보안 경로 변경

Layer / File(s) Summary
보안 인가 규칙과 오류 응답
dms-main/main-infrastructure/src/main/kotlin/team/aliens/dms/global/security/SecurityConfig.kt, dms-main/main-infrastructure/src/main/kotlin/team/aliens/dms/global/security/CustomAuthenticationEntryPoint.kt
/ 경로를 인증 없이 허용합니다. 인증 실패 응답 코드를 FORBIDDEN에서 INVALID_TOKEN으로 변경합니다.
JWT 필터의 선택적 인증 처리
dms-main/main-infrastructure/src/main/kotlin/team/aliens/dms/global/filter/JwtAuthenticationFilter.kt, dms-main/main-infrastructure/src/main/kotlin/team/aliens/dms/global/security/SecurityPaths.kt, dms-main/main-infrastructure/src/test/kotlin/team/aliens/dms/global/filter/JwtAuthenticationFilterTest.kt
경로·메서드 기반 필터 제외 로직과 SecurityPaths를 제거합니다. Authorization 헤더가 없으면 필터 체인을 호출하고, 토큰이 있을 때만 SecurityContext를 설정합니다. 테스트는 여러 경로와 메서드에서 이 동작을 검증합니다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant JwtAuthenticationFilter
  participant SecurityContext
  participant FilterChain
  participant SecurityConfig

  Client->>JwtAuthenticationFilter: HTTP 요청
  alt Authorization 헤더 없음
    JwtAuthenticationFilter->>FilterChain: 인증 없이 전달
  else Authorization 헤더 있음
    JwtAuthenticationFilter->>SecurityContext: 사용자 인증 설정
    JwtAuthenticationFilter->>FilterChain: 인증된 요청 전달
  end
  FilterChain->>SecurityConfig: 인가 규칙 적용
Loading

Possibly related PRs

Suggested reviewers: 4mjeo, ilyoil2, kkm06100

Poem

토끼가 헤더를 살펴보니,
토큰 없으면 조용히 지나가네.
토큰 있으면 인증을 세우고,
루트 길도 활짝 열리네.
INVALID_TOKEN을 품고 깡충! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 permitAll 경로를 SecurityConfig로 일원화하는 주요 변경을 정확히 요약합니다.
Linked Issues check ✅ Passed SecurityPaths 제거, JWT 필터 동작 변경, 루트 경로 허용, INVALID_TOKEN 적용이 이슈 #1045의 요구사항을 충족합니다.
Out of Scope Changes check ✅ Passed 모든 변경은 permitAll 경로 일원화와 인증 오류 처리 개선이라는 이슈 #1045의 범위에 포함됩니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1045-unify-permit-all-paths

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@yellowstarr0323
yellowstarr0323 force-pushed the fix/1045-unify-permit-all-paths branch from c041276 to 607ef4d Compare August 6, 2026 13:34
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

📊 Main Service Coverage Report

Overall Project 14.58% -0.04%
Files changed 57.14% 🍏

File Coverage
JwtAuthenticationFilter.kt 100% 🍏
SecurityConfig.kt 0% -0.52%
CustomAuthenticationEntryPoint.kt 0% -2.9%

@yellowstarr0323 yellowstarr0323 changed the title fix: (#1045) permitAll 경로를 SecurityConfig로 일원화 merge: (#1045) permitAll 경로를 SecurityConfig로 일원화 Aug 6, 2026
@yellowstarr0323

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@dms-main/main-infrastructure/src/main/kotlin/team/aliens/dms/global/security/SecurityConfig.kt`:
- Around line 36-38: 보안 체인 전체를 실행하는 통합 테스트를 추가해 SecurityConfig의 루트 경로 permitAll
설정을 검증하세요. Authorization 헤더 없이 보호된 경로에 요청하고 CustomAuthenticationEntryPoint를 통해
HTTP 401과 INVALID_TOKEN 응답이 반환되는지 확인하며, JwtAuthenticationFilterTest만 수정하지 마세요.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9af633a5-05f9-4f10-99a5-2b22d541b16b

📥 Commits

Reviewing files that changed from the base of the PR and between 8cd793c and 607ef4d.

📒 Files selected for processing (5)
  • dms-main/main-infrastructure/src/main/kotlin/team/aliens/dms/global/filter/JwtAuthenticationFilter.kt
  • dms-main/main-infrastructure/src/main/kotlin/team/aliens/dms/global/security/CustomAuthenticationEntryPoint.kt
  • dms-main/main-infrastructure/src/main/kotlin/team/aliens/dms/global/security/SecurityConfig.kt
  • dms-main/main-infrastructure/src/main/kotlin/team/aliens/dms/global/security/SecurityPaths.kt
  • dms-main/main-infrastructure/src/test/kotlin/team/aliens/dms/global/filter/JwtAuthenticationFilterTest.kt
💤 Files with no reviewable changes (1)
  • dms-main/main-infrastructure/src/main/kotlin/team/aliens/dms/global/security/SecurityPaths.kt

Comment on lines +36 to +38
authorize
.requestMatchers("/").permitAll()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# SecurityConfig 및 인증 진입점의 통합 테스트 존재 여부를 확인합니다.
fd -a -t f '.*(SecurityConfig|CustomAuthenticationEntryPoint).*Test\.kt$' dms-main || true
rg -n -C 4 'SecurityConfig|CustomAuthenticationEntryPoint|INVALID_TOKEN|MockMvc|WebTestClient|"/"' \
  dms-main -g '*Test.kt'

Repository: team-aliens/DMS-Backend

Length of output: 161


🏁 Script executed:

#!/bin/bash
set -u

printf 'Files matching Security/Endpoint/SecurityConfig:\n'
fd -i 'SecurityConfig|AuthenticationEntryPoint|Jwt|Security|Test\.kt$' dms-main 2>/dev/null | sed -n '1,120p' || true

printf '\nSecurityConfig location/content context:\n'
fd -i 'SecurityConfig\.kt$' dms-main | while read -r f; do
  echo "FILE $f"
  wc -l "$f"
  sed -n '1,140p' "$f"
done

printf '\nCustomAuthenticationEntryPoint matches:\n'
rg -n -C 5 'CustomAuthenticationEntryPoint|AuthenticationEntryPoint|INVALID_TOKEN|permitAll|authorize|jwtAuthenticationFilter' dms-main -g '*.kt' || true

printf '\nTest files mentioning MockMvc/WebTestClient/Jwt/Security:\n'
rg -n -C 4 'MockMvc|WebTestClient|JwtAuthentication|Authorization|INVALID_TOKEN|authorizeHttpRequests|permitAll|CustomAuthenticationEntryPoint' dms-main -g '*Test.kt' -g '*.kt' || true

Repository: team-aliens/DMS-Backend

Length of output: 50379


🏁 Script executed:

#!/bin/bash
set -u

printf 'Test files under main-infrastructure/src/test:\n'
fd -a -t f '%Test\.kt$' dms-main/main-infrastructure/src/test 2>/dev/null | sort | sed -n '1,120p'

printf '\nTests mentioning security authorization or paths:\n'
rg -n -C 3 'authorizeHttpRequests|permitAll|hasAuthority|Authorization|"/"|/students/profile|/students|CustomAuthenticationEntryPoint|INVALID_TOKEN|MockMvc|WebTestClient' \
  dms-main/main-infrastructure/src/test -g '*Test.kt' || true

printf '\nInspect JwtAuthenticationFilterTest:\n'
fd -a -t f 'JwtAuthenticationFilterTest.kt' dms-main | while read -r f; do
  echo "FILE $f"
  wc -l "$f"
  sed -n '1,220p' "$f"
done

Repository: team-aliens/DMS-Backend

Length of output: 9720


보안 체인 통합 테스트를 추가하세요.

SecurityConfig"/" permitAll 변경은 JwtAuthenticationFilterTest로는 검증되지 않습니다. 보안 체인 전체를 실행하는 테스트에서 Authorization 없이 필요한 경로에 요청하면 CustomAuthenticationEntryPoint가 401 및 INVALID_TOKEN 응답을 반환하는지 확인하세요.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@dms-main/main-infrastructure/src/main/kotlin/team/aliens/dms/global/security/SecurityConfig.kt`
around lines 36 - 38, 보안 체인 전체를 실행하는 통합 테스트를 추가해 SecurityConfig의 루트 경로 permitAll
설정을 검증하세요. Authorization 헤더 없이 보호된 경로에 요청하고 CustomAuthenticationEntryPoint를 통해
HTTP 401과 INVALID_TOKEN 응답이 반환되는지 확인하며, JwtAuthenticationFilterTest만 수정하지 마세요.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

permitAll 경로가 SecurityConfig와 SecurityPaths 두 곳에서 이중 관리되는 문제

1 participant