TIL

2021.09.03~04 기록장

Gisungcu 2021. 9. 2. 23:38

ToDo

  • 알고리즘 문제 풀기
  • 책 읽기
  • 프로젝트

Done

  • 책 읽기

Weekly goal

  • 책 읽기

 

auto increment와 uuid

 

전자는 디버깅이 쉽고, 클러스터링 인덱스의 경우 insert시 재정렬이 없다. 단점은 분산 시스템 환경에서는 좋지 못하다.

후자는 디버깅이 전자보다 보기 불편하며, 클러스터링 인덱스의 경우 insert시 재정렬이 필요하다. 또한 기존의 auto보다 많은 공간을 차지한다. 장점은 db insert전에 id 값을 알 수 있고, auto_increment를 지원하지 않는 db도 쉽게 사용이 가능하다.

 

https://mareks-082.medium.com/auto-increment-keys-vs-uuid-a74d81f7476a

 

Auto increment keys vs. UUID

Tldr: Programmers should love values and UUID is a value.

mareks-082.medium.com

 

https://uuid.fyi/uuidorint/

 

Primary Key: UUID or Integer

TLDR: Choose Auto Increment Integer if it needs to be exposed externally and readability is important, otherwise, choose UUID. UUID Pros Globally unique. e.g. No false positive for finding items using log search Stateless, it can be generated on the fly. S

uuid.fyi

spring security logout

 

로그아웃 요청이 들어오면 필터에 잡혀서 등록된 url과 맞는지 확인하고 아니면 다른 필터에게 넘긴다.

맞으면 SecurityContext에서 인증 객체를 꺼내서 핸들러에게 넘겨주는데 

핸들러는 세션, 쿠키 삭제를 하고 콘텍스트까지 삭제를 한다.

 

Remember me

 

리멤버 미 필터도 존재하는데 RememberMeAuthenticationFilter이다. 이 필터가 동작할 때는 SecurityContext에 인증 객체가 없거나(세션이 만료될 때) 사용자가 remember me 쿠키를 가지고 올 경우에 발동된다.

 

 RememberMeService인터페이스가 있고 구현체로 Tokenbase와 PersistTokenBase 서비스 2개가 존재한다.

이들이 사용되며 Token을 꺼내서 토큰이 존재하는지, 알맞은 형식인지, DB에 존재하는지를 검사한다.

검증이 모두 통과되면 login 때처럼 인증 객체를 SecurityContext에 넣고 세션에 이 콘텍스트를 다시 넣는다.

이로서 다시 로그인된 것처럼 사용된다.

 

나중에 remember me cookie마저 사용시간이 만료되면 다시 로그인을 해야 할 것이다.