Skip to content

feat : 투표 이벤트 관련 API 비로그인 유저 접근 허용#263

Merged
gisu1102 merged 3 commits intodevelopfrom
feat/poll_event
Oct 7, 2025
Merged

feat : 투표 이벤트 관련 API 비로그인 유저 접근 허용#263
gisu1102 merged 3 commits intodevelopfrom
feat/poll_event

Conversation

@gisu1102
Copy link
Contributor

@gisu1102 gisu1102 commented Oct 4, 2025

feat : 투표 이벤트 관련 API 비로그인 유저 접근 허용

주요 변경사항

Security , jwt.yml

  • 비로그인 접근 허용 API 추가
    • 투표 이벤트 공개 API
      • "/posts/category"
      • "/posts/{postId}"
  • SecurityUtils
    • getCurrentUserIdOrNull()
    • 인증 정보가 없는 경우 null 반환

permitAll 경로에서도 토큰이 있으면 인증 세팅

  • doFilterInternal 내에서 토큰 존재 시 permitAll 여부와 무관하게 인증 컨텍스트 세팅
  • 토큰 미존재 시에만 permitAll 통과

조회수(Hits)

  • 비로그인 유저 조회 시 조회수 증가 비활성화
    • HitsEntity의 userId 필드가 @NotNull로 지정되어 있어 저장 불가
    • 추후 스키마 수정 후 로직 변경 예정 (논의 필요)

차단(Blocking)

  • 인증되지 않은 사용자 요청 시 빈 리스트 반환하도록 변경

@gisu1102 gisu1102 requested review from BHC-Chicken and doma17 October 4, 2025 18:27
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 4, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/poll_event

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 and usage tips.

@doma17
Copy link
Contributor

doma17 commented Oct 5, 2025

스크린샷 2025-10-05 14 16 19

anyRequest().hasRole("USER") 부분을 수정하고 Command 실행에 대한 인증 처리를 모든 엔드포인트에 대해서 추가해야할 것 같아요.

  1. SecurityConfig의 권한 리스트들의 설정을 수정
  2. PreAuthorize()를 모든 Command 실행 엔드포인트에 추가

위의 두가지 옵션이 존재 할 것 같아요.

@gisu1102
Copy link
Contributor Author

gisu1102 commented Oct 6, 2025

fix : permitAll 경로에서도 토큰이 있으면 인증 세팅
doFilterInternal 내에서 토큰 존재 시 permitAll 여부와 무관하게 인증 컨텍스트 세팅
토큰 미존재 시에만 permitAll 통과

에러부분 수정했습니더

@gisu1102
Copy link
Contributor Author

gisu1102 commented Oct 6, 2025

스크린샷 2025-10-05 14 16 19 `anyRequest().hasRole("USER")` 부분을 수정하고 Command 실행에 대한 인증 처리를 모든 엔드포인트에 대해서 추가해야할 것 같아요.
  1. SecurityConfig의 권한 리스트들의 설정을 수정
  2. PreAuthorize()를 모든 Command 실행 엔드포인트에 추가

위의 두가지 옵션이 존재 할 것 같아요.

모든 api url 에 대한 권한을 추가등록 하자는 의미일까요?

현재 Api Url 형식이 command/query 로 나눠져있지않아서 만약 진행한다면 2번이 적절한것같은데 어떠신가요?

@gisu1102
Copy link
Contributor Author

gisu1102 commented Oct 6, 2025

스크린샷 2025-10-05 14 16 19 `anyRequest().hasRole("USER")` 부분을 수정하고 Command 실행에 대한 인증 처리를 모든 엔드포인트에 대해서 추가해야할 것 같아요.
  1. SecurityConfig의 권한 리스트들의 설정을 수정
  2. PreAuthorize()를 모든 Command 실행 엔드포인트에 추가

위의 두가지 옵션이 존재 할 것 같아요.

만약 진행한다면

@doma17
Copy link
Contributor

doma17 commented Oct 7, 2025

스크린샷 2025-10-05 14 16 19 `anyRequest().hasRole("USER")` 부분을 수정하고 Command 실행에 대한 인증 처리를 모든 엔드포인트에 대해서 추가해야할 것 같아요.
  1. SecurityConfig의 권한 리스트들의 설정을 수정
  2. PreAuthorize()를 모든 Command 실행 엔드포인트에 추가

위의 두가지 옵션이 존재 할 것 같아요.

모든 api url 에 대한 권한을 추가등록 하자는 의미일까요?

현재 Api Url 형식이 command/query 로 나눠져있지않아서 만약 진행한다면 2번이 적절한것같은데 어떠신가요?

네 저도 2번 안이 괜찮을 것 같습니다.

제가 말씀드리고 싶은 내용은 조회 쿼리 같은 경우에는 권한 설정이 없어도 될것 같은데.
이전에는 SecurityConfig에서 모든 API가 기본 권한이 'USER'였기 때문에 POST, DELETE와 같은 다른 요청에도 기본 권한이 설정되어 있었습니다.
지금 말씀해주신 방식처럼 모든 엔드포인트에 대해서 기본 권한을 해제시키면 POST, PUT, DELETE와 같은 권한이 없는데도 작동할 수 있기 때문에 모든 API에 대해서 권한을 추가적으로 명시하면 좋을 것 같습니다.

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.

2 participants