Files
keycloak-pattern/docs/evidence/b2-multi-instance-session/README.md
T
DongHyeonkaandClaude Opus 5 711878379c docs: B-2 — sharing the stores fixes one problem and exposes three more
Moving the authorized client to JdbcOAuth2AuthorizedClientService makes tokens work across replicas, so the session-in-Redis plus tokens-in-PostgreSQL split holds. The table then shows what sharing cannot fix: the primary key is (client_registration_id, principal_name) with no session in it, so a second login for the same user updates the same row rather than adding one.

The refresh token sits in bytea as the raw JWT, readable with convert_from, and logout clears only the Redis session while the plaintext token row and the Keycloak SSO session both survive. The schema itself failed silently first because the default DDL uses blob, which PostgreSQL does not have, and continue-on-error swallowed it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 14:15:05 +09:00

1.7 KiB
Raw Blame History

B-2 — 다중 인스턴스 운영 증거

2026-09-04 15:0515:15 KST 해설: docs/experiment-b2-multi-instance-session.md

파일 무엇을 보여주는가
01-jdbc-store-deploy.txt JDBC 저장소로 배포. 테이블이 조용히 안 만들어졌다
02-schema.txt 원인 — 기본 DDL 은 blob(PostgreSQL 에 없음), -postgres.sql 판본이 따로 있다. PRIMARY KEY (client_registration_id, principal_name) — 조회 키 문제가 DDL 에 박혀 있다
03-plaintext-tokens.txt Q3 검증 2번bytea 안이 JWT 문자열 그대로. 디코드하면 {"alg":"HS512",...}
04-overwrite-test.txt Q1 검증 3번 — 같은 사용자 재로그인 시 행 수 1 그대로, issued_at 과 md5 만 바뀜 = UPDATE(덮어쓰기)
05-logout-cleanup.txt Q1 검증 4번 — Redis 0키 / PostgreSQL 1행 잔존 / Keycloak SSO 2세션 잔존
b2-before-relogin.png JDBC 전환 직후, 옛 세션은 여전히 false
b2-tokens-shared-across-instances.png 재로그인 후 accessTokenStoredOnServer: true — 두 replica 에서 동작

핵심 네 줄

  1. 세션 Redis + 토큰 PostgreSQL 분리 저장이 성립한다. B-1 의 "로그인은 됐는데 토큰이 없는" 상태가 해결됐다.
  2. refresh token 은 평문이다. DB 읽기 권한이면 작동하는 토큰을 얻는다.
  3. 같은 사용자의 두 번째 로그인이 첫 번째를 덮어쓴다. 기본키에 session id 가 없어 구조적으로 그렇다.
  4. 로그아웃은 셋 중 하나만 지운다. 평문 토큰과 Keycloak SSO 세션이 남는다.