[TIL] JWT + Spring Security

YJin·2025년 5월 11일

[내배캠 Spring 6기_TIL]

목록 보기
32/56

원래 쓰던 방식
JWT Access 토큰만 사용

여기서 Spring Security를 추가하고 Access + Refresh 토큰 쓰는 걸로 리팩토링

Spring Security

구성 요소

Authentication

인증 객체

JwtFilter

흐름

Http 요청의 Authentication 헤더 부분에서 토큰 추출 (Bearer q2rfQ1AS09 ... 1dAp3=)
Substring 토큰으로 Bearer만 제거
토큰 유효성 검사
유효하다면 인증 객체(Authentication) 생성 후 SecurityContextHolder에 인증 객체 저장

profile
백엔드 개발도 락이다

0개의 댓글