Bugfix: when there are multiple secrets, we should re-sign with latest#118
Closed
rclmenezes wants to merge 2 commits intofastify:masterfrom
Closed
Bugfix: when there are multiple secrets, we should re-sign with latest#118rclmenezes wants to merge 2 commits intofastify:masterfrom
rclmenezes wants to merge 2 commits intofastify:masterfrom
Conversation
Contributor
Author
|
Benchmark: |
4 tasks
0ee908b to
aaf5a03
Compare
rclmenezes
commented
Aug 12, 2022
| [addDataToSession] (prevSession) { | ||
| for (const key in prevSession) { | ||
| if (!['expires', 'cookie'].includes(key)) { | ||
| if (!['expires', 'cookie', 'encryptedSessionId'].includes(key)) { |
Contributor
Author
There was a problem hiding this comment.
The original PR had this change, which is why this bug came up
Anyway, no point in copying encryptedSessionId over if we're going to replace it immediately.
aaf5a03 to
8e5b8a0
Compare
rclmenezes
commented
Aug 12, 2022
| this[cookieOptsKey] = cookieOpts | ||
| this[maxAge] = cookieOpts.maxAge | ||
| this[secretKey] = secret | ||
| this[addDataToSession](prevSession) |
Contributor
Author
There was a problem hiding this comment.
I think this is extremely unreadable and buried. It caused me a lot of confusion earlier, so I decided to put in the function itself
Comment on lines
-102
to
-110
| const plugin = fastifyPlugin(async (fastify, opts) => { | ||
| fastify.addHook('onRequest', (request, reply, done) => { | ||
| request.sessionStore.set(DEFAULT_SESSION_ID, { | ||
| expires: Date.now() + 1000, | ||
| sessionId: DEFAULT_SESSION_ID, | ||
| cookie: { secure: true, httpOnly: true, path: '/' } | ||
| }, done) | ||
| }) | ||
| }) |
Contributor
Author
There was a problem hiding this comment.
Slightly unrelated to the PR. This is unnecessary set-up for this test.
8e5b8a0 to
f5e9205
Compare
Uzlopak
requested changes
Aug 14, 2022
Contributor
Uzlopak
left a comment
There was a problem hiding this comment.
Please dont merge yet. i want to review this more.
Contributor
|
When #125 is merged, the cookie signing will be handled by @fastify/cookie, so we will not need to handled it in @fastify/session again... |
Contributor
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is dependent on:
#120
Only the last commit is relevant for review for now.
Turns out, we were re-signing cookies with the new secret.
Checklist
npm run testandnpm run benchmarkand the Code of conduct