Commit 3d9e87f
Per-Request Auth Token Refresh (#103)
* refactor: simplify token acquisition by removing async calls and unused tests
* Introduce TokenData class
* Passing () to avoid type checking problems
* Test fixups
* fix: update test cases to suppress unused return value warnings, now only scanning relevant files
* Address PR review feedback: preserve token scheme casing and fix documentation (#106)
* Initial plan
* fix: address PR review comments - token scheme, docs, and tests
Co-authored-by: iwillspeak <1004401+iwillspeak@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: iwillspeak <1004401+iwillspeak@users.noreply.github.com>
* chore: remove 'include' and revert removal of .venv from exclude list for pyright
* chore: remove some extraneous comments
* test: consistent casing in assertions and provided mock data
* Address review feedback: require issued_at field and prevent refresh stampede (#107)
* Initial plan
* Implement background token refresh for old tokens
- Add issued_at field to TokenData to track token creation time
- Add is_old() method to check if token should be refreshed (< 50% lifetime)
- Trigger non-blocking background refresh when token is old but valid
- Keep blocking refresh for expired tokens
- Add comprehensive tests for background refresh behavior
Co-authored-by: iwillspeak <1004401+iwillspeak@users.noreply.github.com>
* fix: update tests to match preserved token scheme casing
Tests were expecting capitalized schemes but implementation was
changed in 4b7e73a to preserve server-provided casing.
Co-authored-by: iwillspeak <1004401+iwillspeak@users.noreply.github.com>
* Address code review feedback
- Add logging for background refresh failures
- Improve comments explaining magic numbers
- Add test for server casing preservation
- Add comment explaining test tolerance
Co-authored-by: iwillspeak <1004401+iwillspeak@users.noreply.github.com>
* Address PR review comments
- Make issued_at a required field (remove default value)
- Remove fallback logic for legacy tokens in is_old()
- Add stampede prevention in _background_refresh
- Remove obsolete tests for fallback logic
- Add test for stampede prevention
Co-authored-by: iwillspeak <1004401+iwillspeak@users.noreply.github.com>
* Revert Bearer/DPoP test assertion changes from c50327d
The target branch now properly fixes the test by providing "Bearer"
in the mock data. Reverting my previous fix that changed the assertion
to match the old mock data.
Co-authored-by: anna-singleton-resolver <199753965+anna-singleton-resolver@users.noreply.github.com>
* fix: start refresh thread checks for already refreshed token
* chore: remove extraneous comment
* feat: reduce eagerness of background refresh from at 50% remaining to 25% remaining
* doc: update is_old docstring
* fix: correct boolean logic in _start_background_refresh
Changed from OR to AND logic: refresh should start if
(refresh_not_active AND token_needs_refresh), not if any
condition is true. This prevents unnecessary refresh attempts.
Co-authored-by: iwillspeak <1004401+iwillspeak@users.noreply.github.com>
* test: fix test assertions to be on 25% instead of 50%
* feat: allow configurable proactive_refresh_threshold
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: iwillspeak <1004401+iwillspeak@users.noreply.github.com>
Co-authored-by: anna-singleton-resolver <199753965+anna-singleton-resolver@users.noreply.github.com>
Co-authored-by: anna-singleton-resolver <anna.singleton@resolver.com>
* refactor: TokenData as frozen dataclass and param validity checks at init
* doc: remove old part of docstring
---------
Co-authored-by: Carl Patchett <carl.patchett@kroll.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: iwillspeak <1004401+iwillspeak@users.noreply.github.com>
Co-authored-by: anna-singleton-resolver <anna.singleton@resolver.com>
Co-authored-by: anna-singleton-resolver <199753965+anna-singleton-resolver@users.noreply.github.com>1 parent 6827f3a commit 3d9e87f
9 files changed
Lines changed: 699 additions & 251 deletions
File tree
- docs
- api
- examples
- src/resolver_athena_client/client
- tests
- client
- functional
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
| 133 | + | |
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | 79 | | |
88 | 80 | | |
89 | 81 | | |
| |||
258 | 250 | | |
259 | 251 | | |
260 | 252 | | |
261 | | - | |
| 253 | + | |
262 | 254 | | |
263 | 255 | | |
264 | | - | |
265 | | - | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
266 | 259 | | |
267 | 260 | | |
268 | 261 | | |
| |||
356 | 349 | | |
357 | 350 | | |
358 | 351 | | |
359 | | - | |
360 | | - | |
| 352 | + | |
| 353 | + | |
361 | 354 | | |
362 | 355 | | |
363 | 356 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | 216 | | |
226 | 217 | | |
227 | 218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | 166 | | |
176 | 167 | | |
177 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
0 commit comments