-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 쿠키 적용 후 개발서버에서 에러 발생하는 문제 해결 (#259)
* fix: 캐스팅 대신 인터페이스 메서드 사용하도록 수정 * chore: 테스트 트리거 활성화 * fix: 엑세스 토큰을 헤더에서 추출하는 로직 수정 * refactor: 스웨거 리프레시 토큰 스키마 제거 * fix: 헤더가 null인 경우 파싱하기 전에 Optional로 감싸도록 수정 * fix: 헤더 변환 로직 수정 * fix: 시큐리티 유틸이 멤버 ID 파싱에 실패할 경우 커스텀 예외 던지도록 수정 * feat: 스웨거 API 요청 시 엑세스 토큰 헤더에 포함되도록 설정 변경 * chore: 테스트 트리거 비활성화
- Loading branch information
Showing
3 changed files
with
26 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -1,16 +1,20 @@ | ||
package com.depromeet.global.util; | ||
|
||
import com.depromeet.global.security.PrincipalDetails; | ||
import com.depromeet.global.error.exception.CustomException; | ||
import com.depromeet.global.error.exception.ErrorCode; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class SecurityUtil { | ||
|
||
public Long getCurrentMemberId() { | ||
PrincipalDetails principal = | ||
(PrincipalDetails) | ||
SecurityContextHolder.getContext().getAuthentication().getPrincipal(); | ||
return Long.parseLong(principal.getUsername()); | ||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | ||
try { | ||
return Long.parseLong(authentication.getName()); | ||
} catch (Exception e) { | ||
throw new CustomException(ErrorCode.AUTH_NOT_FOUND); | ||
} | ||
} | ||
} |