[Bug]: Auth0AuthVerifier re-runs OIDC discovery on every construction and discards the result
Auth0AuthVerifier.__init__ calls _discover_jwks_uri(self.auth_domain) and assigns the result to self.jwks_uri. Nothing reads that attribute. _verify_bearer_token gets its key from the module level jwks_client, which was built from the discovery run that happens once at import.
So every construction pays for one requests.get to /.well-known/openid-configuration, with a 10 second timeout, and throws the answer away.
Constructions are not rare. IdentityManagerFactory.get_auth_verifier returns a new instance each call, and it appears in 190 route dependencies, which are evaluated at import time. On AUTH_TYPE=AUTH0 that is roughly 190 discovery requests before the app serves anything. If Auth0 is slow or unreachable they are 190 ten second waits, serialised.
Reproduced on main, discovery stubbed so the count is visible:
after import: 1 request
per construction (x3): 3 requests
jwks_uri attribute: https://example.auth0.com/.well-known/jwks.jsonThe attribute already holds what import discovered, so the second call cannot return anything new for a given AUTH0_DOMAIN.
I have a fix and tests ready if you want it.
Source: keephq/keep