![](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FleLWC%2FbtsepJDDy0v%2FK2A7kMxxlytADUs7RzQI11%2Fimg.png)
개발로그
[개발로그] Security Context 유저 정보와 DB 유저 정보 동기화
Security Context의 정보와 DB의 정보가 다를 때? Spring Security를 세션방식과 함께 이용한다면 로그인 시에 Security Context에 AuthenticationToken(UserDetails, Password, Granted)를 저장하고 세션이 만료되거나 로그아웃 될 때까지 전역적으로 사용할 수 있다. 하지만 로그인 중에 유저 정보가 변해도 Security Context가 들고있는 정보는 업데이트가 되지 않기 때문에 동기화를 시켜줘야한다. 코드 예시 유저 Entity와 Entity를 필드로 갖는 UserDetails를 정의한다. @Entity @Getter @EqualsAndHashCode(of = "id") @NoArgsConstructor public class Acc..