# BFF 가 저장하는 두 가지와 그 조회 키 ## Alternative text 세션 id 로 찾는 Application Session 과 principal 이름으로 찾는 OAuth2AuthorizedClient 가 각각 다른 저장소에 놓인 구성. ## Long description Spring Security 의 자동 구성은 세션을 서블릿 컨테이너 메모리에, authorized client 를 InMemoryOAuth2AuthorizedClientService 에 둔다. 조회 경로가 다른데 이름이 비슷해 하나로 오해하기 쉽다. AuthenticatedPrincipalOAuth2AuthorizedClientRepository 는 principal 이름으로 찾고 조회 키에 session id 가 없다. 그래서 SPRING_SESSION_STORE_TYPE 을 redis 로 바꿔 세션을 옮겨도 토큰은 인스턴스 메모리에 남는다. ## Elements and evidence - **브라우저 요청** (actor): 쿠키에 세션 id 를 담아 온다. Evidence: L326–L331. - **Application Session** (component): 누가 로그인했는지를 담는다. 세션 id 로 찾는다. Evidence: L335–L341. - **OAuth2AuthorizedClient** (component): access · refresh token 을 담는다. principal 이름으로 찾는다. Evidence: L335–L341. - **Redis** (datastore): 세션을 옮긴 곳. B-1 에서 여기까지는 옮겨졌다. Evidence: L347–L351. - **PostgreSQL** (datastore): 토큰을 옮긴 곳. B-2 에서 따로 옮겨야 했다. Evidence: L355–L358. ## Relationships - **OAuth2AuthorizedClient → PostgreSQL:** 저장. Evidence: L355–L358. - **브라우저 요청 → OAuth2AuthorizedClient:** principal 이름으로 조회. Evidence: L332–L341. - **브라우저 요청 → Application Session:** 세션 id 로 조회. Evidence: L326–L331. - **Application Session → Redis:** 저장. Evidence: L347–L351.