Skip to content

Commit b5f8b42

Browse files
Open id metadata cache refresh if key is missing (#1487)
Co-authored-by: Axel Suárez <axsuarez@microsoft.com>
1 parent 1fe7513 commit b5f8b42

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

libraries/botframework-connector/botframework/connector/auth/jwt_token_extractor.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,16 @@ def __init__(self, url):
125125
self.last_updated = datetime.min
126126

127127
async def get(self, key_id: str):
128-
# If keys are more than 5 days old, refresh them
129-
if self.last_updated < (datetime.now() - timedelta(days=5)):
128+
# If keys are more than 1 day old, refresh them
129+
if self.last_updated < (datetime.now() - timedelta(days=1)):
130130
await self._refresh()
131-
return self._find(key_id)
131+
132+
key = self._find(key_id)
133+
if not key and self.last_updated < (datetime.now() - timedelta(hours=1)):
134+
# Refresh the cache if a key is not found (max once per hour)
135+
await self._refresh()
136+
key = self._find(key_id)
137+
return key
132138

133139
async def _refresh(self):
134140
response = requests.get(self.url)

0 commit comments

Comments
 (0)