-
Notifications
You must be signed in to change notification settings - Fork 162
If possible, instantiate connection to JWKS on startup #3795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: a0e6346 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Thanks for the Neo4j GraphQL Toolbox updates. The Neo4j GraphQL Toolbox has now been torn down - reopening this PR will republish it. |
Performance ReportNo Performance Changes Show Full Table
Old Schema Generation: 39.834s |
| if (secret instanceof Uint8Array) { | ||
| debug("Verifying JWT using secret"); | ||
| const { payload } = await jwtVerify(token, secret, this.authorization.verifyOptions); | ||
| return payload; | ||
| } | ||
| debug("Verifying JWKS using url"); | ||
| const { payload } = await jwtVerify(token, secret, this.authorization.verifyOptions); | ||
| return payload; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are now the same. Is there any reason for the if-else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, believe it or not, TypeScript gives an error if you don't do it like this - I don't know if there's a way to resolve this without @ts-ignore.
| return payload; | ||
| } | ||
|
|
||
| private async verifyBearerToken(token: string, secret: Key): Promise<JWTPayload> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verify was changed to receive the resolvedKey all the time, but verifyBearerToken was not. Is there a reason for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually mirrors the previous behaviour - keys were not resolved via callback for Subscriptions. I want to change this in 4.0.0 where we have the better context typings - it's almost too difficult here.
Description
If possible, instantiate connection to JWKS on startup. I was informed that caching was not working between requests, and this was because we were instantiating a new JWKS connection on every request.
This PR, where it can, creates a single connection on startup.
NOTE: Subscriptions are a hot mess ("bearerToken" stuff) - this needs fixing on 4.0.0 where we have better context typings. The context there needs looking at.
Complexity
Complexity: Low