Commit 602d752
fix: Reuse IdP-issued client tokens until near expiry
On the client_secret branch every outbound RPC built a fresh auth-token
factory, manager and OIDCDiscoveryService, paying a discovery GET plus a
token POST per call and discarding the token. All three auth interceptors
invoke it per RPC, so a batch materialization loop multiplied IdP load by
request count and could trip IdP rate limits. Measured before: 5 calls =
5 discovery GETs + 5 token POSTs. After: 1 and 1.
Caches IdP tokens in a module-level dict keyed by the token-request
identity, since the interceptors build a fresh manager per call and
instance state would not survive. Expiry comes from the token's own exp
claim, falling back to the token endpoint's expires_in; a token whose
expiry is unknowable is not cached, preserving per-call behaviour for
opaque tokens.
The cache stores true expiry and applies the caller's
token_refresh_margin_seconds on read, rather than storing a deadline. The
margin is not part of the key, so baking it in let a config with a wider
margin reuse a token past its own safety window when another config
sharing the same credentials had written the entry.
token_refresh_margin_seconds is configurable on OidcClientAuthConfig
(default 30, gt=0) rather than hardcoded.
Inserting on a miss prunes entries whose stored expiry has passed. Keys
are credential identities so the cache is bounded by distinct configs,
but a long-lived process rotating credentials would otherwise retain
every retired identity.
Reuse means a token the IdP revokes mid-life keeps being presented until
its own expiry, where fetching per call self-corrected. Adds
OidcAuthClientManager.invalidate_token and a transport-agnostic
invalidate_auth_token(auth_config), wired into the gRPC interceptor:
an UNAUTHENTICATED response drops the cached token so the next call
refetches, bounding staleness to the rejected request. The call is not
retried, because all four interceptor methods share that path and a
stream's request_iterator may already be consumed.
329 permissions tests pass.
Signed-off-by: Larry Singleton <166439969+larrysingleton007@users.noreply.github.com>1 parent 5fd7af7 commit 602d752
6 files changed
Lines changed: 414 additions & 9 deletions
File tree
- sdk/python
- feast/permissions
- client
- tests/unit/permissions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
Lines changed: 30 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
| |||
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
| 50 | + | |
47 | 51 | | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
52 | 81 | | |
53 | 82 | | |
54 | 83 | | |
| |||
Lines changed: 110 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
| |||
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
16 | 29 | | |
17 | 30 | | |
18 | 31 | | |
| |||
67 | 80 | | |
68 | 81 | | |
69 | 82 | | |
70 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 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 | + | |
71 | 173 | | |
72 | 174 | | |
73 | 175 | | |
| |||
106 | 208 | | |
107 | 209 | | |
108 | 210 | | |
109 | | - | |
| 211 | + | |
| 212 | + | |
110 | 213 | | |
111 | 214 | | |
112 | 215 | | |
113 | 216 | | |
114 | 217 | | |
115 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
116 | 222 | | |
117 | 223 | | |
118 | 224 | | |
| |||
0 commit comments