The keycloak project ended with four open questions that design could not
settle. A two-VM lab was built to answer them by measurement, and this is
that material: 26 experiments, 125 raw command outputs, 22 browser captures.
Follows the import procedure in README.md.
source/ the originating repository verbatim — 78 documents, 28 SVGs,
8 manifests, plus .source-revision recording the commit
final/ the SSOT
document.md 729 lines written from the 29 experiment documents, not
concatenated: what was predicted, what was measured, and
where the measurement itself was wrong
evidence/raw 125 outputs, flattened to <experiment>__<file> because
the originals collided (01-baseline.txt appeared three
times) and the audit only globs the top level
evidence/meta one per raw file; command and exitCode are null and the
README says why rather than inventing them
evidence/browser 22 captures
assets/ three diagrams through techviz
.techviz/ their VizSpecs
A separate project rather than an addition to keycloak: the B-layer answers
that project's four questions, but the A, C and D layers are about cluster
failure, SSO and operations, and one document.md should hold one subject.
The four question records there can point here through 관계.
Recorded rather than papered over: only three of the 28 diagrams were
remade. The repository forbids hand-drawn SVG and forbids titles inside the
canvas; all 28 originals carry both, so converting them is redrawing, not
reformatting. They stay in source/ and the gap is written into the document.
verify-pipeline.py passes. audit-records.py reports no issues.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
116 lines
8.0 KiB
Plaintext
116 lines
8.0 KiB
Plaintext
# 인코더는 패딩을 뗀다
|
|
SignedJsonCursorCodec.java:37 private final Base64.Encoder encoder = Base64.getUrlEncoder().withoutPadding();
|
|
SignedJsonCursorCodec.java:38 private final Base64.Decoder decoder = Base64.getUrlDecoder();
|
|
# 두 상한
|
|
SignedJsonCursorCodec.java:53 /** Longest token this codec will look at, in characters. */
|
|
SignedJsonCursorCodec.java:54 public static final int MAX_ENCODED_LENGTH = 4096;
|
|
SignedJsonCursorCodec.java:55
|
|
SignedJsonCursorCodec.java:56 /** Largest payload this codec will decode, in bytes. */
|
|
SignedJsonCursorCodec.java:57 public static final int MAX_PAYLOAD_BYTES = 2048;
|
|
SignedJsonCursorCodec.java:58
|
|
|
|
# 인코드가 크기를 재는 자리
|
|
SignedJsonCursorCodec.java:63 public String encode(C cursor) {
|
|
SignedJsonCursorCodec.java:64 Objects.requireNonNull(cursor, "cursor");
|
|
SignedJsonCursorCodec.java:65 byte[] json = payloadCodec.toJson(cursor).getBytes(StandardCharsets.UTF_8);
|
|
SignedJsonCursorCodec.java:66 if (json.length > MAX_PAYLOAD_BYTES) {
|
|
SignedJsonCursorCodec.java:67 // The application's own bug, not a caller's: a cursor this large is a payload the codec
|
|
SignedJsonCursorCodec.java:68 // cannot hand back, so producing it would mint a token that fails on the next page.
|
|
SignedJsonCursorCodec.java:69 throw new IllegalStateException(
|
|
SignedJsonCursorCodec.java:70 "cursor payload is " + json.length + " bytes; the bound is " + MAX_PAYLOAD_BYTES);
|
|
SignedJsonCursorCodec.java:71 }
|
|
SignedJsonCursorCodec.java:72 String payload = encoder.encodeToString(json);
|
|
|
|
# 디코드가 크기를 추정하는 자리와 그 식
|
|
SignedJsonCursorCodec.java:103 // Base64 expands by 4/3, so the encoded payload segment's length bounds the decoded size
|
|
SignedJsonCursorCodec.java:104 // exactly. Checking it here refuses an oversized payload without allocating it first.
|
|
SignedJsonCursorCodec.java:105 int encodedPayloadLength = macSeparator - payloadSeparator - 1;
|
|
SignedJsonCursorCodec.java:106 if (decodedLengthOf(encodedPayloadLength) > MAX_PAYLOAD_BYTES) {
|
|
SignedJsonCursorCodec.java:107 throw new IllegalArgumentException("cursor payload exceeds the maximum size");
|
|
SignedJsonCursorCodec.java:108 }
|
|
SignedJsonCursorCodec.java:125 /** The number of bytes a Base64 segment of this many characters decodes to, at most. */
|
|
SignedJsonCursorCodec.java:126 private static int decodedLengthOf(int encodedLength) {
|
|
SignedJsonCursorCodec.java:127 return encodedLength / 4 * 3 + 3;
|
|
SignedJsonCursorCodec.java:128 }
|
|
|
|
# 그 식을 부르는 자리 전부
|
|
adapter/outbound/persistence-jpa · main · SignedJsonCursorCodec.java:106 if (decodedLengthOf(encodedPayloadLength) > MAX_PAYLOAD_BYTES) {
|
|
adapter/outbound/persistence-jpa · main · SignedJsonCursorCodec.java:126 private static int decodedLengthOf(int encodedLength) {
|
|
|
|
# 이 코덱이 프로덕션에 배선되는가
|
|
new SignedJsonCursorCodec 이 나오는 자리 :
|
|
adapter/outbound/persistence-jpa · test · SignedJsonCursorCodecTest.java:22 new SignedJsonCursorCodec<>(new OrderCursorPayloadCodec(), KEY);
|
|
adapter/outbound/persistence-jpa · test · SignedJsonCursorCodecTest.java:40 new SignedJsonCursorCodec<OrderCursor>(
|
|
adapter/outbound/persistence-jpa · test · SignedJsonCursorCodecTest.java:65 () -> new SignedJsonCursorCodec<>(new OrderCursorPayloadCodec(), new byte[16]))
|
|
adapter/outbound/persistence-jpa · test · SignedJsonCursorCodecTest.java:114 new SignedJsonCursorCodec<String>(
|
|
adapter/outbound/persistence-jpa · test · SignedJsonCursorCodecTest.java:179 new SignedJsonCursorCodec<String>(
|
|
adapter/outbound/persistence-jpa · test · SignedJsonCursorCodecTest.java:199 return new SignedJsonCursorCodec<>(
|
|
CursorPayloadCodec 을 구현한다고 선언한 파일 :
|
|
0 개
|
|
실제로 배선된 커서 코덱 :
|
|
HmacGraphQlCursorCodec.java
|
|
HmacWebCursorCodec.java
|
|
MongoKeysetCursorCodec.java
|
|
그 셋이 decodedLengthOf 같은 추정식을 쓰는가 : 0 개
|
|
|
|
# 두 주석이 서로 다르게 적는다
|
|
SignedJsonCursorCodec.java:125 /** The number of bytes a Base64 segment of this many characters decodes to, at most. */
|
|
SignedJsonCursorCodec.java:103 // Base64 expands by 4/3, so the encoded payload segment's length bounds the decoded size
|
|
SignedJsonCursorCodec.java:104 // exactly. Checking it here refuses an oversized payload without allocating it first.
|
|
|
|
# 경계를 시험하는 코드가 있는가
|
|
시험에서 2044 를 쓰는 줄 : 0 개
|
|
시험에서 2045 를 쓰는 줄 : 0 개
|
|
시험에서 2046 를 쓰는 줄 : 0 개
|
|
시험에서 2047 를 쓰는 줄 : 0 개
|
|
시험에서 2048 를 쓰는 줄 : 17 개
|
|
시험에서 2049 를 쓰는 줄 : 1 개
|
|
추정식에 실제로 도달하는 시험 :
|
|
SignedJsonCursorCodecTest.java:166 // Under the token bound and over the payload bound, so the payload check is what fires: the
|
|
SignedJsonCursorCodecTest.java:167 // two are separate limits and the outer one must not be the only thing enforcing either.
|
|
SignedJsonCursorCodecTest.java:168 String payloadSegment = "A".repeat(3000);
|
|
SignedJsonCursorCodecTest.java:169
|
|
SignedJsonCursorCodecTest.java:170 assertThatThrownBy(() -> codec.decode("v1." + payloadSegment + ".AAAA"))
|
|
SignedJsonCursorCodecTest.java:171 .isInstanceOf(IllegalArgumentException.class)
|
|
SignedJsonCursorCodecTest.java:172 .hasMessageContaining("payload exceeds");
|
|
SignedJsonCursorCodecTest.java:173 }
|
|
SignedJsonCursorCodecTest.java:174
|
|
SignedJsonCursorCodecTest.java:175 @Test
|
|
SignedJsonCursorCodecTest.java:176 @DisplayName("encoding a payload past the bound fails as the application's own error")
|
|
왕복을 상한 근처에서 단언하는 시험 : 0 개
|
|
이 코덱을 만드는 자리가 있는 소스 세트 :
|
|
test
|
|
|
|
# 같은 페이로드를 인코드하고 곧바로 디코드해 본 결과
|
|
probe:22 System.out.println(" n 무패딩 L 추정식 패딩 L 추정식 실제 최대 무패딩 초과");
|
|
probe:44 for (int n : new int[] {2044, 2045, 2046, 2047, 2048, 2049}) {
|
|
probe:45 String payload = "a".repeat(n);
|
|
probe:48 token = codec.encode(payload);
|
|
probe:55 codec.decode(token);
|
|
probe:61 int payloadSeg = token.lastIndexOf('.') - token.indexOf('.') - 1;
|
|
probe:63 System.out.printf(" 페이로드 구간 %d 자 · 추정식 %d/4*3+3 = %d%n",
|
|
probe:64 payloadSeg, payloadSeg, payloadSeg / 4 * 3 + 3);
|
|
같은 식을 두 인코딩에 적용하면
|
|
n 무패딩 L 추정식 패딩 L 추정식 실제 최대 무패딩 초과
|
|
2043 2724 2046 2724 2046 2043 3
|
|
2044 2726 2046 2728 2049 2044 2
|
|
2045 2727 2046 2728 2049 2045 1
|
|
2046 2728 2049 2728 2049 2046 3
|
|
2047 2730 2049 2732 2052 2047 2
|
|
2048 2731 2049 2732 2052 2048 1
|
|
2049 2732 2052 2732 2052 2049 3
|
|
|
|
MAX_PAYLOAD_BYTES = 2048 · MAX_ENCODED_LENGTH = 4096
|
|
페이로드 크기 인코드 디코드
|
|
2044 바이트 성공 (토큰 2773 자) 성공
|
|
페이로드 구간 2726 자 · 추정식 2726/4*3+3 = 2046
|
|
2045 바이트 성공 (토큰 2774 자) 성공
|
|
페이로드 구간 2727 자 · 추정식 2727/4*3+3 = 2046
|
|
2046 바이트 성공 (토큰 2775 자) 거절 (cursor payload exceeds the maximum size)
|
|
페이로드 구간 2728 자 · 추정식 2728/4*3+3 = 2049
|
|
2047 바이트 성공 (토큰 2777 자) 거절 (cursor payload exceeds the maximum size)
|
|
페이로드 구간 2730 자 · 추정식 2730/4*3+3 = 2049
|
|
2048 바이트 성공 (토큰 2778 자) 거절 (cursor payload exceeds the maximum size)
|
|
페이로드 구간 2731 자 · 추정식 2731/4*3+3 = 2049
|
|
2049 바이트 거절 (cursor payload is 2049 bytes; the bound is 2048)
|