You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The changes to validate the cognito tokens as part of fetchSession in packages/adapter-nextjs/src/utils/isValidCognitoToken.ts call CognitoJwtVerifier.create on every request (@see125c690#r145308092).
CognitoJwtVerifier creates a cache of the downloaded jwks files. Creating a new instance on every request negates the cache. Which means many calls to get the JWKS file, slowing down each requets.
Prior to this release we were manually verifying the token in our NextJS middleware, since updating noticed a massive increase in the requests to the JWKS file, and a slow down in our test suites.
Expected behavior
That there would be some caching of JWKS file requests, i.e. 1 per application startup
Reproduction steps
In an application that is calling fetchAuthSession.
Thanks for pointing this out @smozely, we are currently exploring a better approach to perform the token validation on the server side, and we will include this performance improvement in the consideration.
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
Authentication
Amplify Version
@aws-amplify/adapter-nextjs: 1.2.1
Introduced by this commit: 125c690
Amplify Categories
auth
Backend
None
Environment information
Describe the bug
The changes to validate the cognito tokens as part of
fetchSession
inpackages/adapter-nextjs/src/utils/isValidCognitoToken.ts
callCognitoJwtVerifier.create
on every request (@see 125c690#r145308092).CognitoJwtVerifier
creates a cache of the downloaded jwks files. Creating a new instance on every request negates the cache. Which means many calls to get the JWKS file, slowing down each requets.Prior to this release we were manually verifying the token in our NextJS middleware, since updating noticed a massive increase in the requests to the JWKS file, and a slow down in our test suites.
Expected behavior
That there would be some caching of JWKS file requests, i.e. 1 per application startup
Reproduction steps
In an application that is calling
fetchAuthSession
.Something like ...
Will make 2 requests to the JWKS file, and will take 100ms at least longer than if its only there once.
Code Snippet
// Put your code below this line.
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: