X Tutup
The Wayback Machine - https://web.archive.org/web/20201218223333/https://github.com/expressjs/session/pull/337
Skip to content
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

Implement custom cookie signature #337

Open
wants to merge 4 commits into
base: master
from

Conversation

@roblabla
Copy link

@roblabla roblabla commented Aug 1, 2016

This is an updated version of #98, that applies properly on current master.

@gabeio gabeio added the pr label Aug 9, 2016
index.js Outdated
@@ -602,8 +606,8 @@ function issecure(req, trustProxy) {
* @private
*/

function setcookie(res, name, val, secret, options) {
var signed = 's:' + signature.sign(val, secret);

This comment has been minimized.

@dougwilson

dougwilson Aug 15, 2016
Member

This change is not backwards-compatible, just as a FYI. It would also make the cookies emitted from here unreadable by other modules trying to decode them without them changing. What is the purpose of this change?

This comment has been minimized.

@roblabla

roblabla Aug 16, 2016
Author

My purpose here was that I need to have full control over the cookie's content. (My end-game is to make express-session compatible with PHP's session management). That means having a "pass-through" signature function (AKA no signature at all).

I have a patch that should (in theory) turn back compatibility while still allowing me to achieve my goals.

@dougwilson
Copy link
Member

@dougwilson dougwilson commented Aug 15, 2016

Looks like the PR is marked as failed because there are not enough tests to cover all the changes made in the PR. Please update the tests to try to cover all added code paths :)

README.md Outdated
Pass in your own cookie signing object/module here that implements the
`sign(value, secret)` and `unsign(value, secret)` functions.

The default value is the `node-cookie-signature` module.

This comment has been minimized.

@dougwilson

dougwilson Aug 15, 2016
Member

Typo here, as this module uses the cookie-signature module, not node-cookie-signature.

This comment has been minimized.

@dougwilson

dougwilson Aug 15, 2016
Member

We could probably include a link to the npm page for the module as well.

index.js Outdated
@@ -78,6 +78,8 @@ var defer = typeof setImmediate === 'function'
* @param {Boolean} [options.saveUninitialized] Save uninitialized sessions to the store
* @param {String|Array} [options.secret] Secret for signing session ID
* @param {Object} [options.store=MemoryStore] Session store
* @param {Object} [options.signature] Object that has the same API as node-cookie-signature

This comment has been minimized.

@dougwilson

dougwilson Aug 15, 2016
Member

Typo: node-cookie-signature -> cookie-signature

Also, I'm not sure we should define our API as "being the same as another module". Perhaps just spell out what we want and just say that cookie-signature is what is following our API, instead of the other way around.

@roblabla
Copy link
Author

@roblabla roblabla commented Aug 16, 2016

Done with all your suggestions :). I think it should be compatible with previous versions now. The s: is only appended in the default signature. In my view, it's the job of the signature module to append it if it needs it (my patch doesn't need it). This allows express-session to be compatible with php's PHPSESSID without much trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.
X Tutup