Commit 41604f3
committed
fix(core): a non-future server cache directive no longer expires the document permanently
`effectiveTtlSeconds()` subtracted the cache timestamp from the server
expiry, so an expiry that was not in the future produced a negative TTL.
`CacheHeaderParser.parseExpiresAt` returns `0` for `Cache-Control:
no-store` and `no-cache`, the current second for `max-age=0`, and a past
epoch for a stale `Expires:` — for `no-store` the result is about
-1.7e9.
A negative TTL is expired on every read, so `get()` took the synchronous
re-fetch branch on the caller's thread every time, forever. The failure
backoff could not cover it: that only arms when a fetch *throws*, and an
endpoint answering `no-store` successfully clears the backoff and
re-arms the expiry on the same call.
This was latent while nothing on a verification path read the metadata
cache. This change series is what puts it there — verification reads
through the cache before every key lookup, and `beforeLookup()` runs
before signature verification, so an unauthenticated caller would have
set the fetch rate against the authorization server. It is the failure
this series exists to remove, reached through a different door.
An expiry at or before the cache timestamp is now read as "no
preference" and the configured interval governs. go-sdk clamps the
equivalent case the same way rather than taking a zero expiry
literally.
Two tests, and the negative control holds: with the clamp removed both
fail and the pre-existing `get_serverExpiresTtl_usesMinOfConfigured...`
still passes, which is why it never covered this — it only exercises a
*future* server expiry.
Also corrects two claims about gate ordering that were not true. The
`requireNoUserinfo` javadoc said it runs "last of the four", and the
changelog said `wellKnownUrl` "enforces the same four gates as the
constructors". The set is the same; the order is not — the three
construction sites run fragment, query, scheme, userinfo and
`wellKnownUrl` runs fragment, scheme, userinfo, query. An identifier
violating two gates can therefore be reported for a different component
depending on the entrypoint. Both reject, so only the message differs;
unifying the four behind one private gate touches four call sites with
different shapes and is left to its own change rather than bolted onto
this one.
990 tests, 0 failures.1 parent 99739a3 commit 41604f3
4 files changed
Lines changed: 120 additions & 5 deletions
File tree
- core/src
- main/java/ai/authplane/sdk/core
- fetching
- prm
- test/java/ai/authplane/sdk/core/fetching
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
24 | 37 | | |
25 | 38 | | |
26 | 39 | | |
| |||
107 | 120 | | |
108 | 121 | | |
109 | 122 | | |
110 | | - | |
| 123 | + | |
| 124 | + | |
111 | 125 | | |
112 | 126 | | |
113 | 127 | | |
| |||
Lines changed: 28 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
366 | 366 | | |
367 | 367 | | |
368 | 368 | | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
369 | 395 | | |
370 | | - | |
371 | | - | |
| 396 | + | |
| 397 | + | |
372 | 398 | | |
373 | 399 | | |
374 | 400 | | |
| |||
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
438 | 438 | | |
439 | 439 | | |
440 | 440 | | |
441 | | - | |
442 | | - | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
443 | 450 | | |
444 | 451 | | |
445 | 452 | | |
| |||
Lines changed: 68 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
139 | 207 | | |
140 | 208 | | |
141 | 209 | | |
| |||
0 commit comments