clerk / clerk-sdk-python

52 stars 15 forks source link

authenticate_request fetches the JWKS repeatedly #54

Open diwu-sf opened 3 weeks ago

diwu-sf commented 3 weeks ago

authenticate_request seem to fetch the jwks repeatedly (function fetch_jwks) to find the right public key.

is it possible to have this cache the public key instead of doing network calls on every authenticate request call? We use authenticate_request as part of our authentication middleware so every API call will trigger this.

kdenz commented 2 weeks ago
        # Authenticate request using Clerk SDK
        auth_state: RequestState = clerk_client.authenticate_request(
            httpx_request,
            AuthenticateRequestOptions(
                jwt_key=settings.CLERK_JWT_KEY,
            ),
        )

Providing JWT key upfront helps for me. Can be found in API Keys page of the Clerk dashboard

image