Skip to content
This repository was archived by the owner on Mar 4, 2024. It is now read-only.

Refactor library - #3

Merged
esarafianou merged 4 commits into
auth0:masterfrom
esarafianou:fixCrypto
Oct 30, 2018
Merged

Refactor library#3
esarafianou merged 4 commits into
auth0:masterfrom
esarafianou:fixCrypto

Conversation

@esarafianou

@esarafianou esarafianou commented Oct 28, 2018

Copy link
Copy Markdown

This PR fixes bugs introduced in #2 and adds one more feature as option.

Highlights

The middleware now overrides res.writeHeads as the initial version did. This is needed, because the middleware must be re-triggered after the user has added some data in req.session in order for the new cookie to be set.

It no longer uses auth0-magic, because all exported functions are asynchronous whereas res.writeHeads cannot work in an asynchronous mode. The aes-256-gcm mode of the node crypto library is now used.

The new feature introduced is the autoRenew option. If set to true, a new cookie will be set in each response with an updated expiration date (Date.now() + timeout). If set to false, the expiration date will be set only the first time data are added to req.session.

Lowlights

  • Added integration tests to avoid bugs like those introduced in the previous PR.
  • Added coverage in tests. The current coverage is 96.2% of lines.

@gkwang gkwang left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nit comments; looks good otherwise. Merge at will.

Comment thread lib/cookie-sessions.js Outdated
});
exports.decrypt = function(secret, ciphertext, iv, authTag) {
try {
var decipher = crypto.createDecipheriv('aes-256-gcm', secret , Buffer.from(iv, 'hex'));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra space before comma

Comment thread lib/cookie-sessions.js Outdated
});
};
}
var splited = exports.split(str)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit spelling. should be splitted.

Comment thread test/cookie-sessions.test.js Outdated
@esarafianou
esarafianou requested a review from a team October 30, 2018 14:59
@esarafianou
esarafianou merged commit 7341810 into auth0:master Oct 30, 2018
@esarafianou
esarafianou deleted the fixCrypto branch October 30, 2018 15:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants