Commit 4b349fc
committed
fix: Reuse the OIDC JWKS client across requests
_decode_token constructed a fresh PyJWKClient on every call. The JWK-set
cache lives on the instance, so every authenticated request started cold
and paid a full HTTPS fetch of the JWKS document (TLS handshake included)
before signature verification. That blocking I/O also runs on the event
loop, so concurrent requests serialized behind it.
Build the client lazily once per parser instead (the parser is
constructed once per process by init_auth_manager), letting PyJWT's
built-in JWK-set cache (default lifespan 300s) do its job. IdP key
rotation stays safe: PyJWKClient.get_signing_key refreshes the set and
retries once whenever it sees an unknown kid.
Local benchmark, 25 authenticated decodes against a mock JWKS endpoint:
25 JWKS fetches before, 1 after.
Signed-off-by: Larry Singleton <166439969+larrysingleton007@users.noreply.github.com>1 parent 79b33ce commit 4b349fc
2 files changed
Lines changed: 61 additions & 15 deletions
File tree
- sdk/python
- feast/permissions/auth
- tests/unit/permissions/auth
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
44 | 72 | | |
45 | 73 | | |
46 | 74 | | |
| |||
125 | 153 | | |
126 | 154 | | |
127 | 155 | | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
| 156 | + | |
143 | 157 | | |
144 | 158 | | |
145 | 159 | | |
| |||
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
671 | 671 | | |
672 | 672 | | |
673 | 673 | | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
674 | 706 | | |
675 | 707 | | |
676 | 708 | | |
| |||
0 commit comments