인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

신민기는위대해요's profile image
신민기는위대해요

asked

Spring Framework in my hands [Spring 1]

82. Additional supplementary explanation (SimpleGrantedAuthority)

UsernamePasswordAuthenticationToken 생성에 대해서 질문이 있습니다.

Resolved

Written on

·

121

0

새로운 Authentication 생성시에,

public Authentication createNewAuthentication(Authentication currentAuth, String username) {
UserDetails newPrincipal = this.loadUserByUsername(username);
UsernamePasswordAuthenticationToken newAuth = new UsernamePasswordAuthenticationToken(newPrincipal, currentAuth.getCredentials(), newPrincipal.getAuthorities());
newAuth.setDetails(currentAuth.getDetails());
return newAuth;
}

위 코드에 관하여 질문드립니다.
currentAuth.getCredentials()는 현재 SecurityContext에 있는 Authentication의 비밀번호를 가져와서 newAuth생성에 쓰임으로 알고있는데요.
이 때, 비밀번호를 수정한 경우에는..
newPrincipal.getCredentials() 라고 고친 메서드를 써야할까요?
아니면 Authentication을 바꿔서 유지해주기보다
로그아웃시켜서 다시 로그인해주는 방식이 옳을까요?

jspspringmvcspring-security

Answer 1

1

bitcocom님의 프로필 이미지
bitcocom
Instructor

이런 경우는 기존 세션을 끊고 로그아웃을 시킨 후 다시 로그인을 해주는 것이 더 좋을듯하겠습니다.

신민기는위대해요's profile image
신민기는위대해요

asked

Ask a question