Skip to content

Commit 0db0767

Browse files
authored
Update README.md
1 parent 2e02db2 commit 0db0767

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -228,18 +228,7 @@ sequenceDiagram
228228
- dofilter 넘어 가기 전 반드시 token에서 Authentication 객체를 SecurityContextHolder 등록 해줘야 한다.
229229
- 등록이 없다면 그 뒤에 AnonymousAuthenticationFilter, ExceptionTranslationFilter, AuthorizationFilter에서 요청이 거부되고 403 혹은 401 에러를 반환한다.
230230
- SecurityContextHolder은 Spring Security 전역 객체라 생각해야한다. 다음 필터들이 인증된 객체를 가지고 security 프로세스를 흘러가기에 요청 쓰레드 마다 인증이 되었다면 인증 객체를 꼭 등록이 필요하다
231-
- **Spring Security 공식 문서에도 나와 있지만 SecurityContextHolder는 기본적으로 스레드 로컬 변수를 사용하여 보안 컨텍스트를 관리하는데, SecurityContextHolder.getContext() 메서드를 사용하여 보안 컨텍스트를 설정할 때, 동일한 보안 컨텍스트를 여러 스레드에서 동시에 접근하고 수정할 가능성이 있기에 꼭 한 쓰레드 마다 별도에 SecurityContext 생성하고 등록 해주자**
232231

233-
```Java
234-
// 인증 객체 발급
235-
AuthenticationToken authenticationToken = jwtTokenProvider.getAuthenticationToken(accessToken);
236-
237-
SecurityContext context = SecurityContextHolder.createEmptyContext();
238-
context.setAuthentication(authenticationToken);
239-
240-
// SecurityContextHolder 인증 객체 저장
241-
SecurityContextHolder.setContext(context);
242-
```
243232

244233
### LogOut 구현
245234

0 commit comments

Comments
 (0)