discord / access

Access, a centralized portal for employees to transparently discover, request, and manage their access for all internal systems needed to do their jobs
Apache License 2.0
311 stars 35 forks source link

Add limited Okta connection pooling #139

Closed barborico closed 1 month ago

barborico commented 1 month ago

Motivation

This PR introduces limited connection pooling for requests from Access to Okta. The intent is to avoid creating excessive connections, e.g. in case of Okta API degradation resulting in timeouts. Although the aiohttp docs for ClientSession state that "it is suggested you use a single session for the lifetime of your application to benefit from connection pooling," this isn't feasible due to the synchronous nature of the Access Flask app. Instead, we introduce a session with each async event loop to call the Okta API. This should at least consolidate retries and paginated requests to a single connection.

Reviewing

Hide whitespace, since most of the changed lines are simply indented.