mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-26 23:44:17 +02:00
fix: upstream token cache expires when refresh expires (#2410)
* fix: upstream token cache expires when refresh expires * fix: handle case where no refresh token provided
This commit is contained in:
parent
d191995840
commit
f7c89e2630
1 changed files with 8 additions and 2 deletions
|
|
@ -1175,7 +1175,8 @@ class OAuthProxy(OAuthProvider):
|
|||
await self._upstream_token_store.put(
|
||||
key=upstream_token_id,
|
||||
value=upstream_token_set,
|
||||
ttl=expires_in, # Auto-expire when access token expires
|
||||
ttl=refresh_expires_in
|
||||
or expires_in, # Auto-expire when refresh token, or access token expires
|
||||
)
|
||||
logger.debug("Stored encrypted upstream tokens (jti=%s)", access_jti[:8])
|
||||
|
||||
|
|
@ -1371,7 +1372,12 @@ class OAuthProxy(OAuthProvider):
|
|||
await self._upstream_token_store.put(
|
||||
key=upstream_token_set.upstream_token_id,
|
||||
value=upstream_token_set,
|
||||
ttl=new_expires_in, # Auto-expire when refreshed access token expires
|
||||
ttl=new_refresh_expires_in
|
||||
or (
|
||||
int(upstream_token_set.refresh_token_expires_at - time.time())
|
||||
if upstream_token_set.refresh_token_expires_at
|
||||
else 60 * 60 * 24 * 30 # Default to 30 days if unknown
|
||||
), # Auto-expire when refresh token expires
|
||||
)
|
||||
|
||||
# Issue new minimal FastMCP access token (just a reference via JTI)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue